Changeset d14840d in mainline
- Timestamp:
- 2017-09-06T17:08:23Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fc3d4fd5
- Parents:
- 42f61f01
- Location:
- uspace/srv/net/tcp
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/tcp/Makefile
r42f61f01 rd14840d 60 60 test/main.c \ 61 61 test/pdu.c \ 62 test/rqueue.c \ 62 63 test/segment.c \ 63 64 test/seq_no.c -
uspace/srv/net/tcp/rqueue.c
r42f61f01 rd14840d 38 38 #include <errno.h> 39 39 #include <io/log.h> 40 #include <stdbool.h> 40 41 #include <stdlib.h> 41 42 #include <fibril.h> 43 #include <fibril_synch.h> 42 44 #include "conn.h" 43 45 #include "pdu.h" … … 56 58 57 59 static prodcons_t rqueue; 60 static bool fibril_active; 61 static fibril_mutex_t lock; 62 static fibril_condvar_t cv; 63 static tcp_rqueue_cb_t *rqueue_cb; 58 64 59 65 /** Initialize segment receive queue. */ 60 void tcp_rqueue_init( void)66 void tcp_rqueue_init(tcp_rqueue_cb_t *rcb) 61 67 { 62 68 prodcons_initialize(&rqueue); 69 fibril_mutex_initialize(&lock); 70 fibril_condvar_initialize(&cv); 71 fibril_active = false; 72 rqueue_cb = rcb; 73 } 74 75 /** Finalize segment receive queue. */ 76 void tcp_rqueue_fini(void) 77 { 78 inet_ep2_t epp; 79 80 inet_ep2_init(&epp); 81 tcp_rqueue_insert_seg(&epp, NULL); 82 83 fibril_mutex_lock(&lock); 84 while (fibril_active) 85 fibril_condvar_wait(&cv, &lock); 86 fibril_mutex_unlock(&lock); 63 87 } 64 88 … … 112 136 { 113 137 tcp_rqueue_entry_t *rqe; 114 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_rqueue_insert_seg()"); 115 116 tcp_segment_dump(seg); 138 139 log_msg(LOG_DEFAULT, LVL_DEBUG2, "tcp_rqueue_insert_seg()"); 140 141 if (seg != NULL) 142 tcp_segment_dump(seg); 117 143 118 144 rqe = calloc(1, sizeof(tcp_rqueue_entry_t)); … … 140 166 rqe = list_get_instance(link, tcp_rqueue_entry_t, link); 141 167 142 tcp_as_segment_arrived(&rqe->epp, rqe->seg); 168 if (rqe->seg == NULL) { 169 free(rqe); 170 break; 171 } 172 173 rqueue_cb->seg_received(&rqe->epp, rqe->seg); 143 174 free(rqe); 144 175 } 145 176 146 /* Not reached */ 177 log_msg(LOG_DEFAULT, LVL_DEBUG2, "tcp_rqueue_fibril() exiting"); 178 179 /* Finished */ 180 fibril_mutex_lock(&lock); 181 fibril_active = false; 182 fibril_mutex_unlock(&lock); 183 fibril_condvar_broadcast(&cv); 184 147 185 return 0; 148 186 } … … 162 200 163 201 fibril_add_ready(fid); 202 fibril_active = true; 164 203 } 165 204 -
uspace/srv/net/tcp/rqueue.h
r42f61f01 rd14840d 39 39 #include "tcp_type.h" 40 40 41 extern void tcp_rqueue_init(void); 41 extern void tcp_rqueue_init(tcp_rqueue_cb_t *); 42 extern void tcp_rqueue_fibril_start(void); 43 extern void tcp_rqueue_fini(void); 42 44 extern void tcp_rqueue_bounce_seg(inet_ep2_t *, tcp_segment_t *); 43 45 extern void tcp_rqueue_insert_seg(inet_ep2_t *, tcp_segment_t *); 44 extern void tcp_rqueue_handler(void *);45 extern void tcp_rqueue_fibril_start(void);46 46 47 47 -
uspace/srv/net/tcp/tcp.c
r42f61f01 rd14840d 47 47 #include "service.h" 48 48 #include "test.h" 49 #include "ucall.h" 49 50 50 51 #define NAME "tcp" 52 53 static tcp_rqueue_cb_t tcp_rqueue_cb = { 54 .seg_received = tcp_as_segment_arrived 55 }; 51 56 52 57 static int tcp_init(void) … … 63 68 } 64 69 65 tcp_rqueue_init( );70 tcp_rqueue_init(&tcp_rqueue_cb); 66 71 tcp_rqueue_fibril_start(); 67 72 -
uspace/srv/net/tcp/tcp_type.h
r42f61f01 rd14840d 280 280 } tcp_rqueue_entry_t; 281 281 282 /** Receive queue callbacks */ 283 typedef struct { 284 /** Segment received */ 285 void (*seg_received)(inet_ep2_t *, tcp_segment_t *); 286 } tcp_rqueue_cb_t; 287 282 288 /** NCSim queue entry */ 283 289 typedef struct { -
uspace/srv/net/tcp/test/main.c
r42f61f01 rd14840d 59 59 PCUT_IMPORT(iqueue); 60 60 PCUT_IMPORT(pdu); 61 PCUT_IMPORT(rqueue); 61 62 PCUT_IMPORT(segment); 62 63 PCUT_IMPORT(seq_no);
Note:
See TracChangeset
for help on using the changeset viewer.