File Conn.c changed (mode: 100644) (index 670110b..727b3e5) |
... |
... |
int Conn_enqueue(struct Conn *C, void *buf, const size_t count) |
271 |
271 |
|
|
272 |
272 |
static void Conn_free_intern(const unsigned int slot) |
static void Conn_free_intern(const unsigned int slot) |
273 |
273 |
{ |
{ |
274 |
|
Log(11, "%s: Cleaning-up id %llu (slot %u) in state %s [%s]...\n", |
|
|
274 |
|
Log(11, "%s: Cleaning-up id %llu (slot=%u) in state %s [%s]...\n", |
275 |
275 |
__FUNCTION__, Conns[slot].id, slot, Conn_state(&Conns[slot]), |
__FUNCTION__, Conns[slot].id, slot, Conn_state(&Conns[slot]), |
276 |
276 |
Conn_errno(&Conns[slot])); |
Conn_errno(&Conns[slot])); |
277 |
277 |
|
|
|
... |
... |
static void Conn_accept(const unsigned int slot) |
787 |
787 |
socklen_t cax_len, sax_len; |
socklen_t cax_len, sax_len; |
788 |
788 |
struct Conn *X; |
struct Conn *X; |
789 |
789 |
|
|
790 |
|
Log(10, "Accepting a connection on slot %u via %s/%d, type %s, domain %s" |
|
|
790 |
|
Log(10, "Accepting a connection on slot=%u via %s/%d, type %s, domain %s" |
791 |
791 |
", protocol %s.\n", |
", protocol %s.\n", |
792 |
792 |
slot, Conns[slot].bind_addr, Conns[slot].bind_port, Conn_type(&Conns[slot]), |
slot, Conns[slot].bind_addr, Conns[slot].bind_port, Conn_type(&Conns[slot]), |
793 |
793 |
Conn_domain(&Conns[slot]), Conn_get_socket_protocol(&Conns[slot])); |
Conn_domain(&Conns[slot]), Conn_get_socket_protocol(&Conns[slot])); |
|
... |
... |
static void Conn_trytoconnect(void) |
977 |
977 |
if (Conns[i].state != CONN_STATE_CONNECT_a) |
if (Conns[i].state != CONN_STATE_CONNECT_a) |
978 |
978 |
continue; |
continue; |
979 |
979 |
|
|
980 |
|
Log(9, "\tTry to connect slot=%u, id=%llu, to %s/%d...\n", |
|
|
980 |
|
Log(9, "\tTrying to connect slot=%u, id=%llu, to %s/%d...\n", |
981 |
981 |
Conns[i].slot, Conns[i].id, Conns[i].addr, Conns[i].port); |
Conns[i].slot, Conns[i].id, Conns[i].addr, Conns[i].port); |
982 |
982 |
|
|
983 |
983 |
memset(&hints, 0, sizeof(hints)); |
memset(&hints, 0, sizeof(hints)); |
|
... |
... |
static void Conn_poll_cb(const unsigned int slot, int revents) |
1290 |
1290 |
} |
} |
1291 |
1291 |
|
|
1292 |
1292 |
/* |
/* |
1293 |
|
* Moving a in-use slot over a free one for compacting reason. |
|
|
1293 |
|
* Moving an in-use slot over a free one for compacting reason. |
1294 |
1294 |
*/ |
*/ |
1295 |
1295 |
static void Conn_move_slot(const unsigned int dst, const unsigned int src) |
static void Conn_move_slot(const unsigned int dst, const unsigned int src) |
1296 |
1296 |
{ |
{ |
|
... |
... |
static void Conn_move_slot(const unsigned int dst, const unsigned int src) |
1299 |
1299 |
if (dst == src) |
if (dst == src) |
1300 |
1300 |
return; |
return; |
1301 |
1301 |
|
|
1302 |
|
Log(10, "\t%s: Moving id %llu from slot %u to slot %d...\n", |
|
|
1302 |
|
Log(10, "\t%s: Moving id %llu from slot=%u to slot=%d...\n", |
1303 |
1303 |
__FUNCTION__, Conns[src].id, src, dst); |
__FUNCTION__, Conns[src].id, src, dst); |
1304 |
1304 |
|
|
1305 |
1305 |
/* We need to save old location because of usefull pointers */ |
/* We need to save old location because of usefull pointers */ |
|
... |
... |
static void Conn_move_slot(const unsigned int dst, const unsigned int src) |
1308 |
1308 |
Conns[src] = tmp; |
Conns[src] = tmp; |
1309 |
1309 |
|
|
1310 |
1310 |
Conns[dst].slot = dst; |
Conns[dst].slot = dst; |
|
1311 |
|
Conns[src].slot = src; |
1311 |
1312 |
|
|
1312 |
1313 |
Conn_engine_move_slot(dst, src); |
Conn_engine_move_slot(dst, src); |
1313 |
1314 |
} |
} |
|
... |
... |
int Conn_poll(const int timeout) |
1360 |
1361 |
|
|
1361 |
1362 |
/* Closing connection if it is in error state */ |
/* Closing connection if it is in error state */ |
1362 |
1363 |
if (Conns[slot].error_state > 0) { |
if (Conns[slot].error_state > 0) { |
1363 |
|
Log(11, "\tSlot %u in error, exchange with pos %u.\n", |
|
|
1364 |
|
Log(11, "\tSlot=%u in error, exchange with pos %u.\n", |
1364 |
1365 |
slot, last); |
slot, last); |
1365 |
1366 |
Conn_move_slot(slot, last); |
Conn_move_slot(slot, last); |
1366 |
1367 |
Conn_free_intern(last); |
Conn_free_intern(last); |
File Conn_engine_core.c changed (mode: 100644) (index 727bb83..50839b9) |
... |
... |
int Conn_try_expand_buf(const unsigned int slot, const int what, const unsigned |
303 |
303 |
if (buf_size - tail >= needed) |
if (buf_size - tail >= needed) |
304 |
304 |
return 0; |
return 0; |
305 |
305 |
|
|
306 |
|
Log(10, "\tTry to expand buffer on slot %u for [%s] needed=%d head=%u tail=%u.\n", |
|
|
306 |
|
Log(10, "\tTry to expand buffer on slot=%u for [%s] needed=%d head=%u tail=%u.\n", |
307 |
307 |
slot, what == 0 ? "o" : "i", needed, |
slot, what == 0 ? "o" : "i", needed, |
308 |
308 |
head, tail); |
head, tail); |
309 |
309 |
|
|
|
... |
... |
void Conn_eat(struct Conn *C, const unsigned int bytes) |
979 |
979 |
Conns[slot].ibuf_tail = 0; |
Conns[slot].ibuf_tail = 0; |
980 |
980 |
} |
} |
981 |
981 |
|
|
982 |
|
Log(10, "Conn_eat(slot %u, %u) head=%u tail=%u qlen=%u\n", |
|
|
982 |
|
Log(10, "Conn_eat(slot=%u, %u) head=%u tail=%u qlen=%u\n", |
983 |
983 |
slot, bytes, Conns[slot].ibuf_head, Conns[slot].ibuf_tail, |
slot, bytes, Conns[slot].ibuf_head, Conns[slot].ibuf_tail, |
984 |
984 |
Conn_qlen(&Conns[slot])); |
Conn_qlen(&Conns[slot])); |
985 |
985 |
} |
} |