Commit 1d721c3a authored by Tommy Olofsson's avatar Tommy Olofsson
Browse files

Fixed some warnings and put in a bunch of prints.

parent 77e60bb7
......@@ -296,6 +296,7 @@ void *firefly_transport_udp_posix_read_run(void *args)
{
struct firefly_transport_llp *llp;
printf("Reader task started\n");
llp = args;
while (true)
firefly_transport_udp_posix_read(llp);
......@@ -336,15 +337,17 @@ int firefly_transport_udp_posix_run(struct firefly_transport_llp *llp)
pthread_cancel(llp_udp->read_thread);
goto fail;
#else
printf("Spawning reader thread\n");
res = taskSpawn("ff_read_thread", 254, 0, 20000,
firefly_transport_udp_posix_read_run,
(FUNCPTR)firefly_transport_udp_posix_read_run,
(int) llp,
0, 0, 0, 0, 0, 0, 0, 0, 0); /* TODO: arg */
if (res == ERROR)
goto fail;
llp_udp->tid_read = res;
printf("Spawning resend thread\n");
res = taskSpawn("ff_resend_thread", 254, 0, 20000,
firefly_resend_run,
(FUNCPTR)firefly_resend_run,
(int) largs,
0, 0, 0, 0, 0, 0, 0, 0, 0); /* TODO: arg */
if (res == ERROR)
......@@ -397,23 +400,27 @@ static int firefly_transport_udp_posix_read_event(void *event_arg)
// Find existing connection or create new.
conn = find_connection(ev_arg->llp, &ev_arg->addr, connection_eq_inaddr);
if (conn == NULL) {
puts("re: new conn");
char ip_addr[INET_ADDRSTRLEN];
sockaddr_in_ipaddr(&ev_arg->addr, ip_addr);
int64_t ev_id = 0;
if (llp_udp->on_conn_recv != NULL &&
(ev_id = llp_udp->on_conn_recv(ev_arg->llp, ip_addr,
sockaddr_in_port(&ev_arg->addr))) > 0) {
sockaddr_in_port(&ev_arg->addr))) > 0)
{
return llp_udp->event_queue->offer_event_cb(llp_udp->event_queue,
FIREFLY_PRIORITY_HIGH,
firefly_transport_udp_posix_read_event,
ev_arg, 1, &ev_id);
} else {
puts("no cb");
free(ev_arg->data);
}
} else {
ev_arg->llp->protocol_data_received_cb(conn, ev_arg->data, ev_arg->len);
}
free(ev_arg);
puts("ev ok");
return 0;
}
......@@ -431,7 +438,9 @@ void firefly_transport_udp_posix_read(struct firefly_transport_llp *llp)
do {
FD_ZERO(&fs);
FD_SET(llp_udp->local_udp_socket, &fs);
/* printf("select\n"); */
res = select(llp_udp->local_udp_socket + 1, &fs, NULL, NULL, NULL);
/* printf("select ret %d\n", res); */
} while (res == -1 && errno == EINTR);
if (res == -1) {
if (errno == ENOMEM) {
......@@ -443,7 +452,7 @@ void firefly_transport_udp_posix_read(struct firefly_transport_llp *llp)
return;
}
#ifdef LABCOMM_COMPAT
res = ioctl(llp_udp->local_udp_socket, FIONREAD, pkg_len);
res = ioctl(llp_udp->local_udp_socket, FIONREAD, (int) &pkg_len);
#else
res = ioctl(llp_udp->local_udp_socket, FIONREAD, &pkg_len);
#endif
......@@ -464,8 +473,10 @@ void firefly_transport_udp_posix_read(struct firefly_transport_llp *llp)
return;
}
len = sizeof(remote_addr);
/* printf("recv %d byte\n", pkg_len); */
res = recvfrom(llp_udp->local_udp_socket, (void *) ev_arg->data, pkg_len, 0,
(struct sockaddr *) &remote_addr, (void *) &len);
/* printf("recv'd %d byte\n", res); */
if (res == -1) {
char err_buf[ERROR_STR_MAX_LEN];
#ifdef LABCOMM_COMPAT
......
......@@ -5,6 +5,7 @@
#include <stdio.h>
#include <utils/firefly_event_queue_vx.h>
#include <utils/firefly_event_queue.h>
#include <utils/firefly_event_queue_private.h>
struct firefly_event_queue_vx_context {
SEM_ID lock;
......@@ -89,14 +90,13 @@ int64_t firefly_event_queue_vx_add(struct firefly_event_queue *eq,
{
int res = 0;
struct firefly_event_queue_vx_context *ctx;
ctx = firefly_event_queue_get_context(eq);
semTake(ctx->lock, WAIT_FOREVER);
res = firefly_event_add(eq, prio, execute, context, nbr_deps, deps);
if (res > 0) {
semGive(ctx->signal);
}
semGive(ctx->lock);
if (res > 0)
semGive(ctx->signal);
return res;
}
......@@ -130,14 +130,18 @@ void *firefly_event_vx_thread_main(void *args)
}
ev = firefly_event_pop(eq);
semGive(ctx->lock);
printf("got ev?\n");
if (ev) {
/* TODO: Retval can indicate badly contructed event, or
* failed execution. Should this be handled?
*/
printf("executing ev. %p\n", ev->execute);
firefly_event_execute(ev);
printf("executing ev done.\n");
semTake(ctx->lock, WAIT_FOREVER);
firefly_event_return(eq, &ev);
semGive(ctx->lock);
printf("event returned\n");
}
}
......@@ -155,7 +159,7 @@ int firefly_event_queue_vx_run(struct firefly_event_queue *eq)
ctx = firefly_event_queue_get_context(eq);
res = taskSpawn("ff_event_task", 254, 0, 20000,
firefly_event_vx_thread_main,
(FUNCPTR)firefly_event_vx_thread_main,
(int) eq, 0, 0, 0, 0, 0, 0, 0, 0, 0);
if (res != ERROR) {
ctx->tid_event_loop = res;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment