diff options
Diffstat (limited to 'hicn-light/src/hicn/core/listener.c')
-rw-r--r-- | hicn-light/src/hicn/core/listener.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/hicn-light/src/hicn/core/listener.c b/hicn-light/src/hicn/core/listener.c index 58ba53fe1..d2f547863 100644 --- a/hicn-light/src/hicn/core/listener.c +++ b/hicn-light/src/hicn/core/listener.c @@ -111,7 +111,8 @@ int listener_initialize(listener_t *listener, face_type_t type, // XXX data should be pre-allocated here loop_fd_event_create(&listener->event_data, MAIN_LOOP, listener->fd, listener, - (fd_callback_t)listener_read_callback, NULL); + (fd_callback_t)listener_read_callback, + CONNECTION_ID_UNDEFINED, NULL); if (!listener->event_data) { goto ERR_REGISTER_FD; @@ -267,7 +268,8 @@ int listener_punt(const listener_t *listener, const char *prefix_s) { return listener_vft[get_protocol(listener->type)]->punt(listener, prefix_s); } -ssize_t listener_read_single(listener_t *listener, int fd) { +ssize_t listener_read_single(listener_t *listener, int fd, + unsigned connection_id) { assert(listener); msgbuf_pool_t *msgbuf_pool = forwarder_get_msgbuf_pool(listener->forwarder); @@ -291,6 +293,7 @@ ssize_t listener_read_single(listener_t *listener, int fd) { } msgbuf_pool_acquire(msgbuf); + msgbuf_set_connection_id(msgbuf, connection_id); // Process received packet size_t processed_bytes = forwarder_receive(listener->forwarder, listener, @@ -308,7 +311,8 @@ ssize_t listener_read_single(listener_t *listener, int fd) { return processed_bytes; } -ssize_t listener_read_batch(listener_t *listener, int fd) { +ssize_t listener_read_batch(listener_t *listener, int fd, + unsigned connection_id) { assert(listener); size_t total_processed_bytes = 0; @@ -356,6 +360,7 @@ ssize_t listener_read_batch(listener_t *listener, int fd) { } msgbuf_pool_acquire(msgbufs[i]); + msgbuf_set_connection_id(msgbufs[i], connection_id); forwarder_acquired_msgbuf_ids_push(forwarder, msgbuf_ids[i]); } @@ -392,10 +397,10 @@ ssize_t listener_read_batch(listener_t *listener, int fd) { * This might be called for a connection on the listener too. The listener is * the entity that owns the buffers used for reading. */ -ssize_t listener_read_callback(listener_t *listener, int fd, void *user_data) { - // DEBUG("[listener_read_callback]"); - // XXX make a single callback and arbitrate between read and readbatch +ssize_t listener_read_callback(listener_t *listener, int fd, + unsigned connection_id, void *user_data) { assert(listener); + assert(!user_data); /* * As the listener callback is shared between the listener and the different @@ -404,9 +409,9 @@ ssize_t listener_read_callback(listener_t *listener, int fd, void *user_data) { // assert(fd == listener->fd); if (listener_vft[get_protocol(listener->type)]->read_batch) - return listener_read_batch(listener, fd); + return listener_read_batch(listener, fd, connection_id); - return listener_read_single(listener, fd); + return listener_read_single(listener, fd, connection_id); } void listener_setup_local(forwarder_t *forwarder, uint16_t port) { |