neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-netif/+/39309?usp=email )
Change subject: api doc: stream.h: hint at how to select modern vs legacy mode
......................................................................
api doc: stream.h: hint at how to select modern vs legacy mode
Change-Id: I651fadb1a00e51f347963418b7a6c5d320580d23
---
M include/osmocom/netif/stream.h
1 file changed, 6 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/09/39309/1
diff --git a/include/osmocom/netif/stream.h b/include/osmocom/netif/stream.h
index a132a27..f63560a 100644
--- a/include/osmocom/netif/stream.h
+++ b/include/osmocom/netif/stream.h
@@ -32,6 +32,9 @@
* For any new applications, you definitely should use the modern mode, as it provides you with a higher
* layer of abstraction and allows you to perform efficient I/O using the io_uring backend of osmo_io.
*
+ * The modern mode is chosen by invoking osmo_stream_srv_create2().
+ * The legacy mode is chosen by invoking the older osmo_stream_srv_create().
+ *
* The two main objects are osmo_stream_srv_link (main server accept()ing incoming connections) and
* osmo_stream_srv (a single given connection from a remote client).
*
@@ -160,6 +163,9 @@
* For any new applications, you definitely should use the modern mode, as it provides you with a higher
* layer of abstraction and allows you to perform efficient I/O using the io_uring backend of osmo_io.
*
+ * The modern mode is chosen by invoking osmo_stream_cli_set_read_cb2().
+ * The legacy mode is chosen by invoking the older osmo_stream_cli_set_read_cb().
+ *
* A typical usage of osmo_stream_cli would look as follows:
*
* * call osmo_stream_cli_create() to create a new osmo_stream_cli
--
To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/39309?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Change-Id: I651fadb1a00e51f347963418b7a6c5d320580d23
Gerrit-Change-Number: 39309
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Attention is currently required from: laforge.
neels has posted comments on this change by laforge. ( https://gerrit.osmocom.org/c/osmo-ci/+/39297?usp=email )
Change subject: remove build2-deb{10,11}build related config
......................................................................
Patch Set 1: Code-Review+1
--
To view, visit https://gerrit.osmocom.org/c/osmo-ci/+/39297?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: osmo-ci
Gerrit-Branch: master
Gerrit-Change-Id: I102e0cad667d8f2cf43c3535169cf3e32e04fca1
Gerrit-Change-Number: 39297
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Comment-Date: Tue, 14 Jan 2025 12:47:27 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-pcap/+/39303?usp=email )
Change subject: server: Avoid lseek syscall on every packet write to pcap file
......................................................................
server: Avoid lseek syscall on every packet write to pcap file
Instead of requesting the current size to the OS, keep track of the
amount of bytes stored in conn->wr_offset, and check agains that value
when we want to write new data to the file.
This should remove quite a lot of oeverhead when lots of traffic is
being handled.
Change-Id: I437eaca982d65d0f06e7d24863875f85267f0e44
---
M include/osmo-pcap/osmo_pcap_server.h
M src/osmo_server_core.c
2 files changed, 22 insertions(+), 16 deletions(-)
Approvals:
osmith: Looks good to me, but someone else must approve
pespin: Looks good to me, approved
laforge: Looks good to me, but someone else must approve
Jenkins Builder: Verified
diff --git a/include/osmo-pcap/osmo_pcap_server.h b/include/osmo-pcap/osmo_pcap_server.h
index 9a44fce..5d21c64 100644
--- a/include/osmo-pcap/osmo_pcap_server.h
+++ b/include/osmo-pcap/osmo_pcap_server.h
@@ -87,6 +87,8 @@
int local_fd;
/* canonicalized absolute pathname of pcap file we write to */
char *curr_filename;
+ /* Current write offset of the file we write to (local_fd) */
+ off_t wr_offset;
/* pcap stuff */
enum osmo_pcap_fmt file_fmt;
diff --git a/src/osmo_server_core.c b/src/osmo_server_core.c
index 819a255..cf526a1 100644
--- a/src/osmo_server_core.c
+++ b/src/osmo_server_core.c
@@ -308,12 +308,17 @@
talloc_free(curr_filename_cpy_dname);
}
+static void close_local_fd(struct osmo_pcap_conn *conn)
+{
+ close(conn->local_fd);
+ conn->local_fd = -1;
+ conn->wr_offset = 0;
+}
+
void osmo_pcap_conn_close_trace(struct osmo_pcap_conn *conn)
{
- if (conn->local_fd >= 0) {
- close(conn->local_fd);
- conn->local_fd = -1;
- }
+ if (conn->local_fd >= 0)
+ close_local_fd(conn);
move_completed_trace_if_needed(conn);
@@ -342,7 +347,7 @@
/* Update conn->last_write if needed. This field is used to keep the last time
* period where we wrote to the pcap file. Once a new write period (based on
* rotation VTY config) is detected, the pcap file we write to is rotated. */
-static void update_last_write(struct osmo_pcap_conn *conn, time_t now)
+static void update_last_write(struct osmo_pcap_conn *conn, time_t now, size_t len)
{
time_t last = mktime(&conn->last_write);
@@ -352,6 +357,8 @@
* using the current one. */
if (now > last)
localtime_r(&now, &conn->last_write);
+
+ conn->wr_offset += len;
}
void osmo_pcap_conn_restart_trace(struct osmo_pcap_conn *conn)
@@ -365,7 +372,7 @@
/* omit any storing/creation of the file */
if (!conn->store) {
- update_last_write(conn, now);
+ update_last_write(conn, now, 0);
talloc_free(conn->curr_filename);
conn->curr_filename = NULL;
return;
@@ -395,16 +402,15 @@
conn->curr_filename, strerror(errno));
return;
}
+ conn->wr_offset = 0;
rc = write(conn->local_fd, conn->file_hdr, conn->file_hdr_len);
if (rc != conn->file_hdr_len) {
LOGP(DSERVER, LOGL_ERROR, "Failed to write the header: %d\n", errno);
- close(conn->local_fd);
- conn->local_fd = -1;
+ close_local_fd(conn);
return;
}
-
- update_last_write(conn, now);
+ update_last_write(conn, now, rc);
}
void osmo_pcap_server_reopen(struct osmo_pcap_server *server)
@@ -425,13 +431,11 @@
/* Returns true if pcap was re-opened */
static bool check_restart_pcap_max_size(struct osmo_pcap_conn *conn, size_t data_len)
{
- off_t cur;
-
if (!pcap_server->max_size_enabled)
return false;
- cur = lseek(conn->local_fd, 0, SEEK_CUR);
- if (cur + data_len <= conn->server->max_size)
+ if (conn->wr_offset + data_len <= conn->server->max_size)
return false;
+
LOGP(DSERVER, LOGL_NOTICE, "Rolling over file for %s (max-size)\n", conn->name);
osmo_pcap_conn_restart_trace(conn);
return true;
@@ -569,7 +573,7 @@
zmq_send_client_data(conn, data, len);
if (!conn->store) {
- update_last_write(conn, now);
+ update_last_write(conn, now, 0);
return 0;
}
@@ -582,11 +586,11 @@
if (!check_restart_pcap_max_size(conn, len))
check_restart_pcap_localtime(conn, now);
- update_last_write(conn, now);
rc = write(conn->local_fd, data, len);
if (rc != len) {
LOGP(DSERVER, LOGL_ERROR, "Failed to write for %s\n", conn->name);
return -1;
}
+ update_last_write(conn, now, rc);
return 0;
}
--
To view, visit https://gerrit.osmocom.org/c/osmo-pcap/+/39303?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: osmo-pcap
Gerrit-Branch: master
Gerrit-Change-Id: I437eaca982d65d0f06e7d24863875f85267f0e44
Gerrit-Change-Number: 39303
Gerrit-PatchSet: 3
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>