pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-pcap/+/39272?usp=email )
Change subject: server: Delay reopen of pcap only until necessary ......................................................................
server: Delay reopen of pcap only until necessary
If we are asked to reopen a pcap file (eg due to external SIGUSR1) while in the middle of receiving a data packet (we already received the header of the segment so data will arrive soon), code exists to delay reopening so that we can include that last packet which arrived because the time where we were asked to reopen. However, the new pcap file was reopened only after next packet arrived. Instead, we want to reopen it as soon as that last packet is received, so that a new pcap file is created. This allows better tracking eg. empty traffic during time in between last data packet before reopen and the next data packet arriving.
While at it, rename the variable to make it more informative, and convert it to a bool.
Change-Id: Id79500717a2e186aac979cded340a5af6ce3035b --- M include/osmo-pcap/osmo_pcap_server.h M src/osmo_server_network.c 2 files changed, 8 insertions(+), 7 deletions(-)
Approvals: Jenkins Builder: Verified osmith: Looks good to me, approved laforge: Looks good to me, but someone else must approve
diff --git a/include/osmo-pcap/osmo_pcap_server.h b/include/osmo-pcap/osmo_pcap_server.h index dad81d3..030a353 100644 --- a/include/osmo-pcap/osmo_pcap_server.h +++ b/include/osmo-pcap/osmo_pcap_server.h @@ -97,7 +97,7 @@ /* read buffering */ int state; int pend; - int reopen; + bool reopen_delayed; struct osmo_pcap_data *data;
/* statistics */ diff --git a/src/osmo_server_network.c b/src/osmo_server_network.c index 55c84cf..7d46b90 100644 --- a/src/osmo_server_network.c +++ b/src/osmo_server_network.c @@ -686,6 +686,12 @@ OSMO_ASSERT(0); }
+ if (conn->reopen_delayed) { + LOGP(DSERVER, LOGL_INFO, "Reopening log for %s now.\n", conn->name); + restart_pcap(conn); + conn->reopen_delayed = false; + } + return rc; }
@@ -693,11 +699,6 @@ static int dispatch_read(struct osmo_pcap_conn *conn) { if (conn->state == STATE_INITIAL) { - if (conn->reopen) { - LOGP(DSERVER, LOGL_INFO, "Reopening log for %s now.\n", conn->name); - restart_pcap(conn); - conn->reopen = 0; - } return read_cb_initial(conn); } else if (conn->state == STATE_DATA) { return read_cb_data(conn); @@ -874,7 +875,7 @@ restart_pcap(conn); } else { LOGP(DSERVER, LOGL_INFO, "Delaying %s until current packet is complete.\n", conn->name); - conn->reopen = 1; + conn->reopen_delayed = true; } } }