Lines Matching refs:pinger
64 pinger_t* pinger; in pinger_close_cb() local
66 pinger = (pinger_t*)handle->data; in pinger_close_cb()
69 pinger->pongs / (TIME / 1000)); in pinger_close_cb()
72 completed_pings += pinger->pongs; in pinger_close_cb()
74 free(pinger); in pinger_close_cb()
77 static void pinger_write_ping(pinger_t* pinger) { in pinger_write_ping() argument
82 r = uv_udp_try_send(&pinger->udp, &buf, 1, in pinger_write_ping()
83 (const struct sockaddr*) &pinger->server_addr); in pinger_write_ping()
94 pinger_t* pinger; in pinger_read_cb() local
95 pinger = (pinger_t*)udp->data; in pinger_read_cb()
102 ASSERT_EQ(buf->base[i], PING[pinger->state]); in pinger_read_cb()
103 pinger->state = (pinger->state + 1) % (sizeof(PING) - 1); in pinger_read_cb()
104 if (pinger->state == 0) { in pinger_read_cb()
105 pinger->pongs++; in pinger_read_cb()
110 pinger_write_ping(pinger); in pinger_read_cb()
119 pinger_t* pinger = malloc(sizeof(*pinger)); in udp_pinger_new() local
122 ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &pinger->server_addr)); in udp_pinger_new()
123 pinger->state = 0; in udp_pinger_new()
124 pinger->pongs = 0; in udp_pinger_new()
127 r = uv_udp_init(loop, &pinger->udp); in udp_pinger_new()
129 r = uv_udp_bind(&pinger->udp, (const struct sockaddr*) &pinger->server_addr, 0); in udp_pinger_new()
132 pinger->udp.data = pinger; in udp_pinger_new()
135 if (0 != uv_udp_recv_start(&pinger->udp, buf_alloc, pinger_read_cb)) { in udp_pinger_new()
138 pinger_write_ping(pinger); in udp_pinger_new()