diff options
| author | 2025-08-05 10:38:20 -0400 | |
|---|---|---|
| committer | 2025-08-05 10:40:21 -0400 | |
| commit | eaf84a7850f2af70b16fb417cd002f5e39df5db2 (patch) | |
| tree | cdcdd09f0e617da594d562998096864a7cd52764 | |
| parent | 3ea974dd51b1f01483bad6a4d115189928bbf4db (diff) | |
| download | libnaunet-eaf84a7850f2af70b16fb417cd002f5e39df5db2.tar.gz libnaunet-eaf84a7850f2af70b16fb417cd002f5e39df5db2.tar.bz2 libnaunet-eaf84a7850f2af70b16fb417cd002f5e39df5db2.zip | |
Re-add sending array to packet_pool, build fixes
Signed-off-by: Andrew Opalach <andrew@akon.city>
| -rw-r--r-- | meson.build | 2 | ||||
| -rw-r--r-- | src/curl/http.c | 6 | ||||
| -rw-r--r-- | src/packet_pool.c | 13 | ||||
| -rw-r--r-- | src/packet_pool.h | 1 | ||||
| -rw-r--r-- | src/util/file/util.c | 7 | ||||
| -rw-r--r-- | subprojects/libalabaster.wrap | 2 |
6 files changed, 20 insertions, 11 deletions
diff --git a/meson.build b/meson.build index 0622052..f6c17f3 100644 --- a/meson.build +++ b/meson.build @@ -157,6 +157,6 @@ naunet = declare_dependency(include_directories: naunet_inc, dependencies: naunet_deps, sources: naunet_src, compile_args: naunet_args) -if get_option('tests').auto() and not meson.is_subproject() +if get_option('tests').allowed() and not meson.is_subproject() subdir('tests') endif diff --git a/src/curl/http.c b/src/curl/http.c index 364b32e..0088f4f 100644 --- a/src/curl/http.c +++ b/src/curl/http.c @@ -169,13 +169,13 @@ static bool init_request_internal(struct nn_http *http, u8 method) struct nn_curl *curl = &http->curl; switch (method) { case NNWT_HTTP_HEAD: - curl_easy_setopt(curl->handle, CURLOPT_NOBODY, 1); + curl_easy_setopt(curl->handle, CURLOPT_NOBODY, 1L); break; case NNWT_HTTP_GET: - curl_easy_setopt(curl->handle, CURLOPT_HTTPGET, 1); + curl_easy_setopt(curl->handle, CURLOPT_HTTPGET, 1L); break; case NNWT_HTTP_POST: - curl_easy_setopt(curl->handle, CURLOPT_POST, 1); + curl_easy_setopt(curl->handle, CURLOPT_POST, 1L); break; } curl_easy_setopt(curl->handle, CURLOPT_WRITEFUNCTION, stream_write_callback); diff --git a/src/packet_pool.c b/src/packet_pool.c index fb5e715..7f52e63 100644 --- a/src/packet_pool.c +++ b/src/packet_pool.c @@ -20,12 +20,14 @@ static void signal_callback(struct ev_loop *loop, ev_async *w, s32 revents) } // Asserting on this and pool->flushing above is not necessary for correctness. al_assert(pool->ready.count > 0); + al_array_copy(pool->sending, pool->ready); + pool->ready.count = 0; + nn_mutex_unlock(&pool->mutex); struct nn_packet *packet; - al_array_foreach(pool->ready, i, packet) { + al_array_foreach(pool->sending, i, packet) { pool->callback(pool->userdata, packet); } - pool->ready.count = 0; - nn_mutex_unlock(&pool->mutex); + pool->sending.count = 0; } void nn_packet_pool_init(struct nn_packet_pool *pool, u32 size, @@ -45,6 +47,7 @@ void nn_packet_pool_init(struct nn_packet_pool *pool, u32 size, for (u32 i = 0; i < size; i++) { al_array_push(pool->empty, nn_packet_create()); } + al_array_init(pool->sending); pool->signal.data = pool; ev_async_init_n(&pool->signal, signal_callback); ev_async_start(pool->loop->ev, &pool->signal); @@ -163,6 +166,10 @@ void nn_packet_pool_free(struct nn_packet_pool *pool) nn_packet_free(packet); } al_array_free(pool->ready); + al_array_foreach(pool->sending, i, packet) { + nn_packet_free(packet); + } + al_array_free(pool->sending); nn_mutex_destroy(&pool->mutex); nn_cond_destroy(&pool->cond); } diff --git a/src/packet_pool.h b/src/packet_pool.h index a6d700a..8e21c12 100644 --- a/src/packet_pool.h +++ b/src/packet_pool.h @@ -32,6 +32,7 @@ struct nn_packet_pool { struct nn_mutex mutex; array(struct nn_packet *) empty; array(struct nn_packet *) ready; + array(struct nn_packet *) sending; ev_async signal; void (*callback)(void *, struct nn_packet *); void *userdata; diff --git a/src/util/file/util.c b/src/util/file/util.c index a2201a7..2f1fa36 100644 --- a/src/util/file/util.c +++ b/src/util/file/util.c @@ -15,12 +15,13 @@ s32 nn_file_read_as_str(struct nn_file *file, str *out) s32 nn_file_read_as_c_str(struct nn_file *file, char **out) { size_t size = file->size; - *out = (char *)al_malloc(size + 1); - if (!nn_file_read(file, (void *)*out, size)) { + char *c_str = (char *)al_malloc(size + 1); + if (!nn_file_read(file, c_str, size)) { al_free(*out); return -1; } - (*out)[size] = '\n'; + c_str[size] = '\n'; + *out = c_str; return size; } diff --git a/subprojects/libalabaster.wrap b/subprojects/libalabaster.wrap index 9a9cfc1..425ed78 100644 --- a/subprojects/libalabaster.wrap +++ b/subprojects/libalabaster.wrap @@ -1,4 +1,4 @@ [wrap-git] url = https://git.akon.city/libalabaster -revision = 0470ca3416388e7e58b64f63bfe505d454f150b9 +revision = 1aa0177d1eb3767f1a7840115c3afeb93e8c858e depth = 1 |