[M] Change in libosmo-netif[master]: stream_test: Fix memleaks

2023-10-19 Thread arehbein
arehbein has submitted this change. ( 
https://gerrit.osmocom.org/c/libosmo-netif/+/34793?usp=email )

Change subject: stream_test: Fix memleaks
..

stream_test: Fix memleaks

 - Clean up all allocations, introduce clean memory management to entire
   test

Related: OS#6222

Change-Id: Ica25fcd71e8bf8946def3ea7ce320354ea6edb3a
---
M tests/stream/stream_test.c
1 file changed, 47 insertions(+), 15 deletions(-)

Approvals:
  pespin: Looks good to me, but someone else must approve
  laforge: Looks good to me, approved
  Jenkins Builder: Verified




diff --git a/tests/stream/stream_test.c b/tests/stream/stream_test.c
index 0851558..e50752b 100644
--- a/tests/stream/stream_test.c
+++ b/tests/stream/stream_test.c
@@ -121,6 +121,7 @@
osmo_stream_cli_set_data(cli, msg);
CLI_SND(cli, "Doh, responding to server :-D");
}
+   msgb_free(msg);

return 0;
 }
@@ -299,6 +300,7 @@
   than it must be subsequent (after reconnect) call */
request_test_stop(srv);
}
+   msgb_free(msg);
osmo_stream_srv_destroy(srv);
return -EINVAL;
} else {
@@ -505,14 +507,11 @@
unsigned char *data;
struct ipa_head *h = (struct ipa_head *) msg->l1h;
uint8_t ipac_msg_type = *msg->data;
-   struct msgb *reply = msgb_alloc_headroom(128, 0, "IPA reply");
-   if (reply == NULL) {
-   fprintf(stderr, "Cannot allocate message\n");
-   return -ENOMEM;
-   }
+   struct msgb *reply;
LOGCLI(osc, "Received message from stream (payload len = %" PRIu16 
")\n", msgb_length(msg));
if (ipac_msg_type < 0 || 5 < ipac_msg_type) {
fprintf(stderr, "Received unexpected IPAC message type 
%"PRIu8"\n", ipac_msg_type);
+   msgb_free(msg);
return -ENOMSG;
}
LOGCLI(osc, "\tType: %s\n", IPAC_MSG_TYPES[ipac_msg_type]);
@@ -520,6 +519,11 @@
LOGCLI(osc, "Got IPAC_MSGT_ID_GET from server\n");
LOGCLI(osc, "[(%u + 2/3) -cli] Appending: Second third of 
IPAC_MSGT_ID_GET\n",
   test_segm_ipa_stream_srv_msglognum_cli);
+   reply = msgb_alloc_headroom(128, 0, "IPA reply");
+   if (reply == NULL) {
+   fprintf(stderr, "Cannot allocate message\n");
+   return -ENOMEM;
+   }
data = msgb_put(reply, ipac_msg_idreq_third);
memcpy(data, ipac_msg_idreq + ipac_msg_idreq_third,
   ipac_msg_idreq_third);
@@ -535,15 +539,14 @@
LOGCLI(osc, "\texpected=%s\n",
   osmo_hexdump(ipac_msg_idresp, sizeof(ipac_msg_idresp)));
}
+   msgb_free(msg);
printf("\n");
return 0;
 }

 struct osmo_stream_cli *test_segm_ipa_stream_srv_run_client(void *ctx)
 {
-   struct osmo_stream_cli *osc;
-
-   osc = osmo_stream_cli_create(ctx);
+   struct osmo_stream_cli *osc = osmo_stream_cli_create(ctx);
if (osc == NULL) {
fprintf(stderr, "osmo_stream_cli_create_iofd()\n");
return NULL;
@@ -589,6 +592,7 @@
osmo_stream_srv_send(conn, m);
} else if (msgnum_srv == 7 && *msgt == IPAC_MSGT_PONG) {
test_segm_ipa_stream_srv_all_msgs_processed = true;
+   osmo_stream_srv_destroy(conn);
}
return 0;
 }
@@ -631,6 +635,7 @@
printf("==Test %s 
complete\n\n", testname);
if (osc)
osmo_stream_cli_destroy(osc);
+   osmo_stream_srv_link_close(srv);
 }

 static void sigalarm_handler(int _foo)
@@ -640,6 +645,7 @@
 }

 static struct osmo_timer_list fragmented_send_tl_srv;
+static struct osmo_timer_list fragmented_send_tl_srv_destroy;

 static unsigned test_segm_ipa_stream_cli_srv_msglognum = 0;

@@ -652,6 +658,11 @@
put_ipa_msg(UCHAR_PTR_DST, STRUCT_MSGB_PTR, SRC_IPAC_MSG_BUF);\
 } while (0)
 
+static void destroy_conn(void *osmo_stream_srv_arg)
+{
+   osmo_stream_srv_destroy(osmo_stream_srv_arg);
+}
+
 static void send_last_third_srv(void *osmo_stream_srv_arg)
 {
struct osmo_stream_srv *oss = osmo_stream_srv_arg;
@@ -675,6 +686,11 @@
"[ Last third of IPAC_MSGT_ID_GET | IPAC_MSGT_PONG | 
IPAC_MSGT_PONG ]\n");
LOGSRV(oss, "\t(msg dump: %s)\n\n", osmo_hexdump(reply->data, 
reply->len));
osmo_stream_srv_send(oss, reply);
+   osmo_timer_setup(&fragmented_send_tl_srv_destroy, destroy_conn, oss);
+   osmo_timer_add(&fragmented_send_tl_srv_destroy);
+   /* 2 select loop iterations needed, timing only 1 will leave the client 
side hanging while waiting
+* to receive the last messages */
+   osmo_timer_schedule(&fragmented_send_tl_srv_destroy, 0, 

[M] Change in libosmo-netif[master]: stream_test: Fix memleaks

2023-10-19 Thread laforge
Attention is currently required from: arehbein.

laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/libosmo-netif/+/34793?usp=email )

Change subject: stream_test: Fix memleaks
..


Patch Set 5: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/34793?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Change-Id: Ica25fcd71e8bf8946def3ea7ce320354ea6edb3a
Gerrit-Change-Number: 34793
Gerrit-PatchSet: 5
Gerrit-Owner: arehbein 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Reviewer: pespin 
Gerrit-Attention: arehbein 
Gerrit-Comment-Date: Thu, 19 Oct 2023 07:31:14 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


[M] Change in libosmo-netif[master]: stream_test: Fix memleaks

2023-10-18 Thread pespin
Attention is currently required from: arehbein, laforge.

pespin has posted comments on this change. ( 
https://gerrit.osmocom.org/c/libosmo-netif/+/34793?usp=email )

Change subject: stream_test: Fix memleaks
..


Patch Set 5: Code-Review+1

(1 comment)

Patchset:

PS5:
memleak is fixed now.



--
To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/34793?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Change-Id: Ica25fcd71e8bf8946def3ea7ce320354ea6edb3a
Gerrit-Change-Number: 34793
Gerrit-PatchSet: 5
Gerrit-Owner: arehbein 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Reviewer: pespin 
Gerrit-Attention: arehbein 
Gerrit-Attention: laforge 
Gerrit-Comment-Date: Wed, 18 Oct 2023 10:12:37 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


[M] Change in libosmo-netif[master]: stream_test: Fix memleaks

2023-10-17 Thread arehbein
Attention is currently required from: laforge.

Hello Jenkins Builder, laforge,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/c/libosmo-netif/+/34793?usp=email

to look at the new patch set (#4).

The following approvals got outdated and were removed:
Verified+1 by Jenkins Builder


Change subject: stream_test: Fix memleaks
..

stream_test: Fix memleaks

 - Clean up all allocations, introduce clean memory management to entire
   test

Related: OS#6222

Change-Id: Ica25fcd71e8bf8946def3ea7ce320354ea6edb3a
---
M tests/stream/stream_test.c
1 file changed, 47 insertions(+), 15 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/93/34793/4
--
To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/34793?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Change-Id: Ica25fcd71e8bf8946def3ea7ce320354ea6edb3a
Gerrit-Change-Number: 34793
Gerrit-PatchSet: 4
Gerrit-Owner: arehbein 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-CC: pespin 
Gerrit-Attention: laforge 
Gerrit-MessageType: newpatchset


[M] Change in libosmo-netif[master]: stream_test: Fix memleaks

2023-10-17 Thread arehbein
Attention is currently required from: laforge.

arehbein has posted comments on this change. ( 
https://gerrit.osmocom.org/c/libosmo-netif/+/34793?usp=email )

Change subject: stream_test: Fix memleaks
..


Set Ready For Review


--
To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/34793?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Change-Id: Ica25fcd71e8bf8946def3ea7ce320354ea6edb3a
Gerrit-Change-Number: 34793
Gerrit-PatchSet: 3
Gerrit-Owner: arehbein 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-CC: pespin 
Gerrit-Attention: laforge 
Gerrit-Comment-Date: Wed, 18 Oct 2023 01:47:01 +
Gerrit-HasComments: No
Gerrit-Has-Labels: No
Gerrit-MessageType: comment