summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Henry <joseph.henry@zerotier.com>2015-10-09 15:05:45 -0400
committerJoseph Henry <joseph.henry@zerotier.com>2015-10-09 15:05:45 -0400
commit769bad332041fd707533c086dc0d2c2f4a57befe (patch)
tree053578d9c50449a006f43cb1c45981c540e9d9eb
parent6600b005b611ef1a44b51fd54c770df82a5aafc9 (diff)
downloadinfinitytier-769bad332041fd707533c086dc0d2c2f4a57befe.tar.gz
infinitytier-769bad332041fd707533c086dc0d2c2f4a57befe.zip
Test: Added handle_write call to nc_poll
-rw-r--r--netcon/NetconEthernetTap.cpp50
1 files changed, 26 insertions, 24 deletions
diff --git a/netcon/NetconEthernetTap.cpp b/netcon/NetconEthernetTap.cpp
index e6a1736d..79ddb238 100644
--- a/netcon/NetconEthernetTap.cpp
+++ b/netcon/NetconEthernetTap.cpp
@@ -344,7 +344,6 @@ void NetconEthernetTap::threadMain()
if (since_tcp >= ZT_LWIP_TCP_TIMER_INTERVAL) {
prev_tcp_time = now;
lwipstack->tcp_tmr();
- //fprintf(stderr, "tcp_tmr\n");
} else {
tcp_remaining = ZT_LWIP_TCP_TIMER_INTERVAL - since_tcp;
}
@@ -354,7 +353,6 @@ void NetconEthernetTap::threadMain()
} else {
etharp_remaining = ARP_TMR_INTERVAL - since_etharp;
}
- //fprintf(stderr, "poll_wait_time = %d\n", (unsigned long)std::min(tcp_remaining,etharp_remaining));
_phy.poll((unsigned long)std::min(tcp_remaining,etharp_remaining));
}
closeAll();
@@ -477,27 +475,6 @@ int NetconEthernetTap::send_return_value(TcpConnection *conn, int retval)
// locked in this case!
/*
- * Callback from LWIP to do whatever work we might need to do.
- *
- * @param associated service state object
- * @param PCB we're polling on
- * @return ERR_OK if everything is ok, -1 otherwise
- *
- */
-err_t NetconEthernetTap::nc_poll(void* arg, struct tcp_pcb *tpcb)
-{
- //fprintf(stderr, "nc_poll\n");
- /*
- Larg *l = (Larg*)arg;
- TcpConnection *conn = l->conn;
- NetconEthernetTap *tap = l->tap;
- if(conn && conn->idx) // if valid connection and non-zero index (indicating data present)
- tap->handle_write(conn);
- */
- return ERR_OK;
-}
-
-/*
* Callback from LWIP for when a connection has been accepted and the PCB has been
* put into an ACCEPT state.
*
@@ -552,7 +529,7 @@ err_t NetconEthernetTap::nc_accept(void *arg, struct tcp_pcb *newpcb, err_t err)
tap->lwipstack->_tcp_recv(newpcb, nc_recved);
tap->lwipstack->_tcp_err(newpcb, nc_err);
tap->lwipstack->_tcp_sent(newpcb, nc_sent);
- tap->lwipstack->_tcp_poll(newpcb, nc_poll, 1);
+ tap->lwipstack->_tcp_poll(newpcb, nc_poll, 0.5);
tcp_accepted(conn->pcb);
return ERR_OK;
}
@@ -639,6 +616,29 @@ void NetconEthernetTap::nc_err(void *arg, err_t err)
}
/*
+ * Callback from LWIP to do whatever work we might need to do.
+ *
+ * @param associated service state object
+ * @param PCB we're polling on
+ * @return ERR_OK if everything is ok, -1 otherwise
+ *
+ */
+err_t NetconEthernetTap::nc_poll(void* arg, struct tcp_pcb *tpcb)
+{
+ uint64_t now = OSUtils::now();
+ //fprintf(stderr, "nc_poll(): now = %u\n", now);
+ //fprintf(stderr, "nc_poll\n");
+
+ Larg *l = (Larg*)arg;
+ TcpConnection *conn = l->conn;
+ NetconEthernetTap *tap = l->tap;
+ if(conn && conn->idx) // if valid connection and non-zero index (indicating data present)
+ tap->handle_write(conn);
+
+ return ERR_OK;
+}
+
+/*
* Callback from LWIP to signal that 'len' bytes have successfully been sent.
* As a result, we should put our socket back into a notify-on-readability state
* since there is now room on the PCB buffer to write to.
@@ -657,6 +657,8 @@ err_t NetconEthernetTap::nc_sent(void* arg, struct tcp_pcb *tpcb, u16_t len)
if(len) {
//fprintf(stderr, "ACKING len = %d, setting read-notify = true, (sndbuf = %d)\n", len, l->conn->pcb->snd_buf);
l->tap->_phy.setNotifyReadable(l->conn->dataSock, true);
+ //uint64_t now = OSUtils::now();
+ //fprintf(stderr, "nc_sent(): now = %u\n", now);
//l->tap->_phy.whack();
//l->tap->handle_write(l->conn);
}