Changeset d14840d in mainline for uspace/srv/net/tcp/rqueue.c
- 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note:
See TracChangeset
for help on using the changeset viewer.