Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • dap/dap-sdk
1 result
Show changes
Commits on Source (24)
......@@ -251,8 +251,8 @@ endif ()
if ( CELLFRAME_NO_OPTIMIZATION)
if (PLATFORM_X86_64)
set(CMAKE_CXX_FLAGS "-march=core2")
set(CMAKE_C_FLAGS "-march=core2")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=core2")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=core2")
endif()
set(DAP_CRYPTO_XKCP_PLAINC ON)
endif ()
......
......@@ -3,6 +3,7 @@
#include <string.h>
#include "dap_enc_dilithium.h"
#include "dap_enc.h"
#include "dap_common.h"
#include "rand/dap_rand.h"
......@@ -13,7 +14,6 @@ static enum DAP_DILITHIUM_SIGN_SECURITY _dilithium_type = DILITHIUM_MIN_SIZE; //
//// WARNING! Its because of accident with wrong sizes on mobile 32bit platforms
//// Remove it after you'll update all mobile keys
void dap_enc_sig_dilithium_set_type(enum DAP_DILITHIUM_SIGN_SECURITY type)
{
_dilithium_type = type;
......@@ -83,7 +83,7 @@ int dap_enc_sig_dilithium_verify_sign(dap_enc_key_t *a_key, const void *a_msg,
}
int l_ret = dilithium_crypto_sign_open( (unsigned char *)a_msg, a_msg_size, (dilithium_signature_t *)a_sig, a_key->pub_key_data);
if(l_ret)
log_it(L_WARNING,"Wrong signature, can't open with code %d", l_ret);
debug_if(dap_enc_debug_more(), L_WARNING, "Wrong signature, can't open with code %d", l_ret);
return l_ret;
}
......
......@@ -927,9 +927,10 @@ static void *s_dap_events_socket_buf_thread(void *arg)
l_es, l_es->fd2);
case -1:
pthread_rwlock_wrlock(&l_es->buf_out_lock);
if (l_es->cb_buf_cleaner)
l_es->cb_buf_cleaner((char*)l_es->buf_out, l_es->buf_out_size);
if (l_es->cb_buf_cleaner) {
size_t l_dropped = l_es->cb_buf_cleaner((char*)l_es->buf_out, l_es->buf_out_size);
log_it(L_INFO, "Drop %zu bytes on es %p (%d)", l_dropped, l_es, l_es->fd2);
}
l_es->buf_out_size = 0;
pthread_rwlock_unlock(&l_es->buf_out_lock);
pthread_exit(NULL);
......
......@@ -22,24 +22,23 @@
*/
#if defined(DAP_OS_WINDOWS)
#ifdef DAP_EVENTS_CAPS_WEPOLL
#include "wepoll.h"
#endif
#include <ws2tcpip.h>
#elif defined(DAP_OS_LINUX)
#else
#include <arpa/inet.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <sys/socket.h>
#include <sys/epoll.h>
#include <netdb.h>
#include <sys/timerfd.h>
#include <sys/un.h>
#if defined(DAP_OS_LINUX)
#include <sys/epoll.h>
#include <sys/timerfd.h>
#elif defined (DAP_OS_BSD)
#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/event.h>
#include <sys/un.h>
#include <netdb.h>
#endif
#endif
#include <sys/types.h>
......@@ -370,6 +369,9 @@ static void s_es_server_accept(dap_events_socket_t *a_es_listener, SOCKET a_remo
l_es_new->remote_port = strtol(l_port_str, NULL, 10);
debug_if(l_server->ext_log, L_INFO, "Connection accepted from %s : %hu, socket %"DAP_FORMAT_SOCKET,
l_es_new->remote_addr_str, l_es_new->remote_port, a_remote_socket);
int one = 1;
if ( setsockopt(l_es_new->socket, IPPROTO_TCP, TCP_NODELAY, (const char*)&one, sizeof(one)) < 0 )
log_it(L_WARNING, "Can't disable Nagle alg, error %d: %s", errno, dap_strerror(errno));
break;
default:
log_it(L_ERROR, "Unsupported protocol family %hu from accept()", l_family);
......
......@@ -174,6 +174,7 @@ static void s_http_connected(dap_events_socket_t * a_esocket)
if (!l_client_http->timer) {
DAP_DELETE(l_es_uuid_ptr);
log_it(L_ERROR, "Can't run timerfo after connection check on worker id %u", l_client_http->worker->id);
return;
}
char l_request_headers[1024] = { [0]='\0' };
......@@ -219,11 +220,28 @@ static void s_http_connected(dap_events_socket_t * a_esocket)
#ifdef DAP_EVENTS_CAPS_IOCP
a_esocket->no_close = true;
#endif
dap_events_socket_write_f_unsafe(a_esocket, "%s /%s%s HTTP/1.1\r\n" "Host: %s\r\n" "%s\r\n" "%s",
l_client_http->method, l_client_http->path, l_get_str,
l_client_http->uplink_addr, l_request_headers,
l_client_http->request && l_client_http->request_size
? (char*)l_client_http->request : "");
char *l_out_buf = NULL;
int l_header_size = asprintf(&l_out_buf, "%s /%s%s HTTP/1.1\r\n" "Host: %s\r\n" "%s\r\n",
l_client_http->method, l_client_http->path, l_get_str,
l_client_http->uplink_addr, l_request_headers);
if(!l_out_buf || l_header_size == -1){
log_it(L_ERROR, "Can't create headers string or memory allocation error.");
return;
}
ssize_t l_out_buf_size = l_header_size;
if (l_client_http->request && l_client_http->request_size){
l_out_buf_size += l_client_http->request_size + 1;
l_out_buf = DAP_REALLOC(l_out_buf, l_out_buf_size);
memcpy(l_out_buf + l_header_size, l_client_http->request, l_client_http->request_size);
}
dap_events_socket_write_unsafe(a_esocket, l_out_buf, l_out_buf_size);
DAP_DEL_Z(l_out_buf);
}
/**
......
......@@ -493,6 +493,10 @@ void dap_http_client_read( dap_events_socket_t *a_esocket, void *a_arg )
} else if (l_http_client->proc->cache)
// No data, its over
dap_http_client_write(l_http_client);
else {
a_esocket->buf_in_size = 0;
break;
}
}
dap_events_socket_shrink_buf_in( a_esocket, l_len); /* Shrink input buffer over whole HTTP header */
} break;
......@@ -562,13 +566,15 @@ void dap_http_client_write(dap_http_client_t *a_http_client)
"%s: %s" CRLF, hdr->name, hdr->value);
dap_http_header_remove( &a_http_client->out_headers, hdr );
}
dap_events_socket_write_unsafe(a_http_client->esocket, CRLF, 2);/* Add final CRLF - HTTP's End-Of-Header */
dap_events_socket_write_unsafe(a_http_client->esocket, CRLF, 2); /* Add final CRLF - HTTP's End-Of-Header */
}
bool dap_http_client_write_callback(dap_events_socket_t *a_esocket, void *a_arg)
{
dap_return_val_if_fail(a_esocket, false);
dap_http_client_t *l_http_client = DAP_HTTP_CLIENT(a_esocket);
if (!l_http_client)
return false;
if (l_http_client->reply_status_code != Http_Status_OK || l_http_client->state_read == DAP_HTTP_CLIENT_STATE_NONE) {
// No write data if error code set
l_http_client->esocket->flags |= DAP_SOCK_SIGNAL_CLOSE;
......
......@@ -245,9 +245,9 @@ int dap_stream_ch_pkt_send_by_addr(dap_stream_node_addr_t *a_addr, const char a_
{
dap_worker_t *l_worker = NULL;
dap_events_socket_uuid_t l_es_uuid = dap_stream_find_by_addr(a_addr, &l_worker);
if (!l_worker)
return -1;
return dap_stream_ch_pkt_send_mt(DAP_STREAM_WORKER(l_worker), l_es_uuid, a_ch_id, a_type, a_data, a_data_size);
return l_worker
? dap_stream_ch_pkt_send_mt(DAP_STREAM_WORKER(l_worker), l_es_uuid, a_ch_id, a_type, a_data, a_data_size)
: -1;
}
/**
......
......@@ -158,11 +158,12 @@ ret_n_clear:
static size_t s_cb_msg_buf_clean(char *a_buf_out, size_t a_buf_size)
{
for (size_t shift = 0; shift < a_buf_size; shift += sizeof( dap_stream_worker_msg_send_t*)) {
dap_stream_worker_msg_send_t* l_msg = (dap_stream_worker_msg_send_t*)(a_buf_out + shift);
size_t l_total_size = 0;
for (size_t shift = 0; shift < a_buf_size; shift += sizeof(dap_stream_worker_msg_send_t*)) {
dap_stream_worker_msg_send_t* l_msg = *(dap_stream_worker_msg_send_t**)(a_buf_out + shift);
l_total_size += l_msg->data_size;
DAP_DELETE(l_msg->data);
DAP_DELETE(l_msg);
log_it(L_WARNING, "MSG BUF CLEAN!");
}
return 0;
return l_total_size;
}