summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--meson.build2
-rw-r--r--src/common.c2
-rw-r--r--src/packet_stream.c3
-rw-r--r--src/socket/socket_linux.c4
-rw-r--r--src/socket/socket_windows.c2
-rw-r--r--tests/timer_loop.c4
6 files changed, 9 insertions, 8 deletions
diff --git a/meson.build b/meson.build
index f6c17f3..067fb57 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').allowed() and not meson.is_subproject()
+if get_option('tests').allowed()
subdir('tests')
endif
diff --git a/src/common.c b/src/common.c
index 797090d..7034971 100644
--- a/src/common.c
+++ b/src/common.c
@@ -86,7 +86,7 @@ bool nn_common_init(const char *thread_name)
free, malloc_lock, malloc_unlock);
#endif
- al_rand_init((u32)(nn_get_timestamp() / 1000));
+ al_rand_init((u32)(nn_get_timestamp() / 1000000));
#ifdef NAUNET_ON_WINDOWS
if (!nn_windows_init()) return false;
diff --git a/src/packet_stream.c b/src/packet_stream.c
index b183df5..0cf296c 100644
--- a/src/packet_stream.c
+++ b/src/packet_stream.c
@@ -40,7 +40,8 @@ static void shutdown_internal(struct nn_packet_stream *stream)
static void discard_out_queue_internal(struct nn_packet_stream *stream)
{
- al_assert(!stream->out.running);
+ // stream->out.running can be true here. The stream will stop the
+ // write event by itself if the out queue is empty.
if (stream->out.packet) {
stream->packet_sent_callback(stream->userdata, stream->out.packet);
stream->out.packet = NULL;
diff --git a/src/socket/socket_linux.c b/src/socket/socket_linux.c
index 70d9184..6a97556 100644
--- a/src/socket/socket_linux.c
+++ b/src/socket/socket_linux.c
@@ -219,11 +219,11 @@ bool nn_socket_accept(struct nn_socket *sock, struct nn_socket *cl, s32 flags)
port = ntohs(saddr->sin6_port);
inet_ntop(AF_INET6, &saddr->sin6_addr, addr_str, sizeof(addr_str));
}
- log_debug("Connection from %s:%hu.", addr_str, port);
+ log_info("Connection from %s:%hu.", addr_str, port);
break;
}
case NNWT_SOCKET_UNIX:
- log_debug("Connection on UNIX socket.");
+ log_info("Connection on UNIX socket.");
break;
}
diff --git a/src/socket/socket_windows.c b/src/socket/socket_windows.c
index 69fa55b..3cf316f 100644
--- a/src/socket/socket_windows.c
+++ b/src/socket/socket_windows.c
@@ -113,7 +113,7 @@ bool nn_socket_connect(struct nn_socket *sock, str *addr, u16 port)
s32 ret = connect(sock->fd, (SOCKADDR *)&sock->addr_in, sizeof(sock->addr_in));
if (ret == SOCKET_ERROR && WSAGetLastError() != WSAEWOULDBLOCK) {
- log_error("connect() failed: %d.", WSAGetLastError());
+ log_error("connect(%.*s:%hu) failed: %d.", nn_addr_x(addr), port, WSAGetLastError());
return false;
}
diff --git a/tests/timer_loop.c b/tests/timer_loop.c
index a9ce283..a90f7c0 100644
--- a/tests/timer_loop.c
+++ b/tests/timer_loop.c
@@ -19,8 +19,8 @@ static void timer_callback(void *userdata, struct nn_timer *timer)
s64 adj = iter * DELAY - (s64)diff;
al_printf("[%2u (%llu)] %fs(%s%f)\n", iter, now, diff / 1000000.0, adj >= 0 ? "+" : "", adj / 1000000.0);
nn_timer_set_repeat(timer, NNWT_TS_FROM_USEC(MAX(DELAY + adj, (s64)1)));
- if (++iter == REPEAT) nn_timer_stop(timer);
- else nn_timer_again(timer);
+ if (iter++ == 0) nn_timer_again(timer);
+ else if (iter == REPEAT) nn_timer_stop(timer);
}
s32 main(void)