Changes in uspace/srv/net/tcp/rqueue.c [9520af7:2f19103] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/tcp/rqueue.c
r9520af7 r2f19103 38 38 #include <errno.h> 39 39 #include <io/log.h> 40 #include <stdbool.h>41 40 #include <stdlib.h> 42 41 #include <fibril.h> 43 #include <fibril_synch.h>44 42 #include "conn.h" 43 #include "pdu.h" 45 44 #include "rqueue.h" 46 45 #include "segment.h" … … 48 47 #include "ucall.h" 49 48 49 /** Transcode bounced segments. 50 * 51 * If defined, segments bounced via the internal debugging loopback will 52 * be encoded to a PDU and the decoded. Otherwise they will be bounced back 53 * directly without passing the encoder-decoder. 54 */ 55 #define BOUNCE_TRANSCODE 56 50 57 static prodcons_t rqueue; 51 static bool fibril_active;52 static fibril_mutex_t lock;53 static fibril_condvar_t cv;54 static tcp_rqueue_cb_t *rqueue_cb;55 58 56 59 /** Initialize segment receive queue. */ 57 void tcp_rqueue_init( tcp_rqueue_cb_t *rcb)60 void tcp_rqueue_init(void) 58 61 { 59 62 prodcons_initialize(&rqueue); 60 fibril_mutex_initialize(&lock);61 fibril_condvar_initialize(&cv);62 fibril_active = false;63 rqueue_cb = rcb;64 63 } 65 64 66 /** Finalize segment receive queue. */ 67 void tcp_rqueue_fini(void) 65 /** Bounce segment directy into receive queue without constructing the PDU. 66 * 67 * This is for testing purposes only. 68 * 69 * @param sp Endpoint pair, oriented for transmission 70 * @param seg Segment 71 */ 72 void tcp_rqueue_bounce_seg(inet_ep2_t *epp, tcp_segment_t *seg) 68 73 { 69 inet_ep2_t epp;74 inet_ep2_t rident; 70 75 71 inet_ep2_init(&epp); 72 tcp_rqueue_insert_seg(&epp, NULL); 76 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_rqueue_bounce_seg()"); 73 77 74 fibril_mutex_lock(&lock); 75 while (fibril_active) 76 fibril_condvar_wait(&cv, &lock); 77 fibril_mutex_unlock(&lock); 78 #ifdef BOUNCE_TRANSCODE 79 tcp_pdu_t *pdu; 80 tcp_segment_t *dseg; 81 82 if (tcp_pdu_encode(epp, seg, &pdu) != EOK) { 83 log_msg(LOG_DEFAULT, LVL_WARN, "Not enough memory. Segment dropped."); 84 return; 85 } 86 87 if (tcp_pdu_decode(pdu, &rident, &dseg) != EOK) { 88 log_msg(LOG_DEFAULT, LVL_WARN, "Not enough memory. Segment dropped."); 89 return; 90 } 91 92 tcp_pdu_delete(pdu); 93 94 /** Insert decoded segment into rqueue */ 95 tcp_rqueue_insert_seg(&rident, dseg); 96 tcp_segment_delete(seg); 97 #else 98 /* Reverse the identification */ 99 tcp_ep2_flipped(epp, &rident); 100 101 /* Insert segment back into rqueue */ 102 tcp_rqueue_insert_seg(&rident, seg); 103 #endif 78 104 } 79 105 … … 81 107 * 82 108 * @param epp Endpoint pair, oriented for reception 83 * @param seg Segment (ownership transferred to rqueue)109 * @param seg Segment 84 110 */ 85 111 void tcp_rqueue_insert_seg(inet_ep2_t *epp, tcp_segment_t *seg) 86 112 { 87 113 tcp_rqueue_entry_t *rqe; 114 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_rqueue_insert_seg()"); 88 115 89 log_msg(LOG_DEFAULT, LVL_DEBUG2, "tcp_rqueue_insert_seg()"); 90 91 if (seg != NULL) 92 tcp_segment_dump(seg); 116 tcp_segment_dump(seg); 93 117 94 118 rqe = calloc(1, sizeof(tcp_rqueue_entry_t)); … … 116 140 rqe = list_get_instance(link, tcp_rqueue_entry_t, link); 117 141 118 if (rqe->seg == NULL) { 119 free(rqe); 120 break; 121 } 122 123 rqueue_cb->seg_received(&rqe->epp, rqe->seg); 142 tcp_as_segment_arrived(&rqe->epp, rqe->seg); 124 143 free(rqe); 125 144 } 126 145 127 log_msg(LOG_DEFAULT, LVL_DEBUG2, "tcp_rqueue_fibril() exiting"); 128 129 /* Finished */ 130 fibril_mutex_lock(&lock); 131 fibril_active = false; 132 fibril_mutex_unlock(&lock); 133 fibril_condvar_broadcast(&cv); 134 146 /* Not reached */ 135 147 return 0; 136 148 } … … 150 162 151 163 fibril_add_ready(fid); 152 fibril_active = true;153 164 } 154 165
Note:
See TracChangeset
for help on using the changeset viewer.