pespin has uploaded this change for review. (
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(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-pcap refs/changes/72/39272/1
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 f4f6b06..d57b42b 100644
--- a/src/osmo_server_network.c
+++ b/src/osmo_server_network.c
@@ -684,6 +684,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;
}
@@ -691,11 +697,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);
@@ -872,7 +873,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;
}
}
}
--
To view, visit
https://gerrit.osmocom.org/c/osmo-pcap/+/39272?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: osmo-pcap
Gerrit-Branch: master
Gerrit-Change-Id: Id79500717a2e186aac979cded340a5af6ce3035b
Gerrit-Change-Number: 39272
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>