Re: [PATCH] avoid bearerbox oom-kill (fix)
Hi Alexander, ok, I tried to understand the patch. Here is what I sum up: Within gw/bb_boxc.c:boxc_receiver() you create a msg of type ack and fill it with values depending on the result of the smsc2_rout() call. ok so far ok. Then you inject the ack msg to conn-incoming. But I don't see any usage of that queue within smsbox? So the question is: where is the ack msg used after this? Stipe [EMAIL PROTECTED] --- Wapme Systems AG Vogelsanger Weg 80 40470 Düsseldorf Tel: +49-211-74845-0 Fax: +49-211-74845-299 E-Mail: [EMAIL PROTECTED] Internet: http://www.wapme-systems.de --- wapme.net - wherever you are
Re: [PATCH] avoid bearerbox oom-kill (fix)
Hi Stipe, On Sunday 17 November 2002 15:05, you wrote: Hi Alexander, ok, I tried to understand the patch. Here is what I sum up: Within gw/bb_boxc.c:boxc_receiver() you create a msg of type ack and fill it with values depending on the result of the smsc2_rout() call. ok so far ok. you are right here.. Then you inject the ack msg to conn-incoming. But I don't see any usage of that queue within smsbox? So the question is: where is the ack msg used after this? Please see boxc_sender : if ((msg = list_consume(conn-incoming)) == NULL) { ... } boxc_sender is consumer of this list ... We don't use smsbox and generated ack will not be used within smsbox. This should be implemented ;) If you want I can do this ? Regards Alex Stipe [EMAIL PROTECTED] --- Wapme Systems AG Vogelsanger Weg 80 40470 Düsseldorf Tel: +49-211-74845-0 Fax: +49-211-74845-299 E-Mail: [EMAIL PROTECTED] Internet: http://www.wapme-systems.de --- wapme.net - wherever you are -- Mit besten Grüßen aus Köln Dipl.-Ing. Alexander Malysh ___ Centrium GmbH Ehrenstrasse 2 50672 Köln Fon: +49 (0221) 277 49 150 Fax: +49 (0221) 277 49 109 email: [EMAIL PROTECTED] web: http://www.centrium.de
Re: [PATCH] avoid bearerbox oom-kill (fix)
please re submit this patch as a unified diff, and ignoring changes to white space. This is horrid to read as there are many lines in the diff that are not necessary. yep, Nisan is right here. The more cleanly your patch is, the faster we may review it and vote for commitment to cvs. Stipe [EMAIL PROTECTED] --- Wapme Systems AG Vogelsanger Weg 80 40470 Düsseldorf Tel: +49-211-74845-0 Fax: +49-211-74845-299 E-Mail: [EMAIL PROTECTED] Internet: http://www.wapme-systems.de --- wapme.net - wherever you are
[PATCH] Avoid bearerbox oom-kill!
Hi List, here is a small patch to avoid bearerbox oom-kill and give smsbox really status of sms. OOM-Kill simple scenario: your bearerbox is connected to SMSC but connection is broken (temporarely). So smsbox send sms to bearerbox (bbbox) and bbbox store it in queue (list) and sometimes is bbbox too large im mem (in worst case will be killed from kernel). Now you can define in config maximum-queue-length (applies for both queues) and bbbox send ack/nack to smsbox. For MO traffic I have added saying return codes , so each ptocol layer can use this (I beleave it's better as just -1 and protocol layer don't know why?) Comments? -- Mit besten Grüßen aus Köln Dipl.-Ing. Alexander Malysh ___ Centrium GmbH Ehrenstraße 2 50672 Köln Fon: +49 (0221) 277 49 150 Fax: +49 (0221) 277 49 109 email: [EMAIL PROTECTED] web: www.centrium.de Index: gw/bb_boxc.c === RCS file: /home/cvs/gateway/gw/bb_boxc.c,v retrieving revision 1.59 diff -a -u -r1.59 bb_boxc.c --- gw/bb_boxc.c 14 Nov 2002 02:29:25 - 1.59 +++ gw/bb_boxc.c 15 Nov 2002 12:57:37 - @@ -42,7 +42,7 @@ static List *smsbox_list = NULL; /* dictionaries for holding the smsbox routing information */ -static Dict *smsbox_by_id = NULL; +static Dict *smsbox_by_id = NULL; static Dict *smsbox_by_smsc = NULL; static Dict *smsbox_by_receiver = NULL; @@ -56,7 +56,7 @@ static long boxid = 0; -extern Mutex *boxid_mutex; +extern Mutex *boxid_mutex; typedef struct _boxc { @@ -108,7 +108,7 @@ return NULL; } } - + if (pack == NULL) return NULL; @@ -124,7 +124,8 @@ static void boxc_receiver(void *arg) { Boxc *conn = arg; -Msg *msg; +Msg *msg, *mack; +int rc; /* remove messages from socket until it is closed */ while (bb_status != BB_DEAD conn-alive) { @@ -133,35 +134,49 @@ msg = read_from_box(conn); -if (msg == NULL) { /* garbage/connection lost */ -conn-alive = 0; -break; -} - -if (msg_type(msg) == sms conn-is_wap == 0) { -debug(bb.boxc, 0, boxc_receiver: sms received); + if (msg == NULL) { /* garbage/connection lost */ + conn-alive = 0; + break; + } -/* - * XXX save modifies ID, so if the smsbox uses it, save - * it FIRST for the reply message!!! - */ -store_save(msg); -if (smsc2_rout(msg)== -1) { -warning(0, Message rejected by bearerbox, no router!); -/* send NACK */ -bb_smscconn_send_failed(NULL, msg, SMSCCONN_FAILED_DISCARDED); -} -if (msg-sms.sms_type == mt_push) { -/* - * XXX generate ack-message and send it - in fact, this - * should include information did it succeed, wa sit queued - * or rejected... - */ -} + if (msg_type(msg) == sms conn-is_wap == 0) { + debug(bb.boxc, 0, boxc_receiver: sms received); + /* save modifies ID, so if the smsbox uses it, save + * it FIRST for the reply message!!! + * generate ack-message and send it - in fact, this + * should include information did it succeed, wa sit queued + * or rejected... + */ + mack = msg_create(ack); + mack-ack.id = msg-sms.id; + mack-ack.time = msg-sms.time; + store_save(msg); + rc = smsc2_rout(msg); + switch (rc) { + case -1: + warning(0, Message rejected by bearerbox, no router !); + /* send NACK */ + bb_smscconn_send_failed(NULL, msg, SMSCCONN_FAILED_DISCARDED); + mack-ack.nack = ack_failed; + break; + case -2: + warning(0, Message rejected by bearerbox, queue full !); + /* send NACK */ + bb_smscconn_send_failed(NULL, msg, SMSCCONN_FAILED_DISCARDED); + mack-ack.nack = ack_failed_tmp; + break; + case 0: + mack-ack.nack = ack_buffered; + break; + case 1: + mack-ack.nack = ack_success; + break; + } + list_produce(conn-incoming, mack); } else if (msg_type(msg) == wdp_datagram conn-is_wap) { debug(bb.boxc, 0, boxc_receiver: got wdp from wapbox); - + list_produce(conn-outgoing, msg); } else if (msg_type(msg) == sms conn-is_wap) { @@ -189,10 +204,10 @@ else if (msg_type(msg) == admin msg-admin.command == cmd_identify) { List *newlist; -/* and add the boxc_ud into conn for boxc_status() output */ +/* and add the boxc_id into conn for boxc_status() output */ if (conn-boxc_id == NULL) conn-boxc_id = octstr_duplicate(msg-admin.boxc_id); -/*
Re: [PATCH] Avoid bearerbox oom-kill!
here is a small patch to avoid bearerbox oom-kill and give smsbox really status of sms. OOM-Kill simple scenario: your bearerbox is connected to SMSC but connection is broken (temporarely). So smsbox send sms to bearerbox (bbbox) and bbbox store it in queue (list) and sometimes is bbbox too large im mem (in worst case will be killed from kernel). Now you can define in config maximum-queue-length (applies for both queues) and bbbox send ack/nack to smsbox. For MO traffic I have added saying return codes , so each ptocol layer can use this (I beleave it's better as just -1 and protocol layer don't know why?) Hi Alexander, could you please sum up what the patch does. I see that you do something with the queues, but it's a bit wakky to read the patch (it's not very clean, in terms of tabs and indents and such beasts :)) Stipe [EMAIL PROTECTED] --- Wapme Systems AG Vogelsanger Weg 80 40470 Düsseldorf Tel: +49-211-74845-0 Fax: +49-211-74845-299 E-Mail: [EMAIL PROTECTED] Internet: http://www.wapme-systems.de --- wapme.net - wherever you are
[PATCH] avoid bearerbox oom-kill (fix)
Hi, this is the same oom-kill patch with memleak bugfix. -- Mit besten Grüßen aus Köln Dipl.-Ing. Alexander Malysh ___ Centrium GmbH Ehrenstraße 2 50672 Köln Fon: +49 (0221) 277 49 150 Fax: +49 (0221) 277 49 109 email: [EMAIL PROTECTED] web: www.centrium.de Index: gw/bb_boxc.c === RCS file: /home/cvs/gateway/gw/bb_boxc.c,v retrieving revision 1.59 diff -a -u -r1.59 bb_boxc.c --- gw/bb_boxc.c 14 Nov 2002 02:29:25 - 1.59 +++ gw/bb_boxc.c 15 Nov 2002 17:41:17 - @@ -42,7 +42,7 @@ static List *smsbox_list = NULL; /* dictionaries for holding the smsbox routing information */ -static Dict *smsbox_by_id = NULL; +static Dict *smsbox_by_id = NULL; static Dict *smsbox_by_smsc = NULL; static Dict *smsbox_by_receiver = NULL; @@ -56,7 +56,7 @@ static long boxid = 0; -extern Mutex *boxid_mutex; +extern Mutex *boxid_mutex; typedef struct _boxc { @@ -108,7 +108,7 @@ return NULL; } } - + if (pack == NULL) return NULL; @@ -124,7 +124,8 @@ static void boxc_receiver(void *arg) { Boxc *conn = arg; -Msg *msg; +Msg *msg, *mack; +int rc; /* remove messages from socket until it is closed */ while (bb_status != BB_DEAD conn-alive) { @@ -133,42 +134,56 @@ msg = read_from_box(conn); -if (msg == NULL) { /* garbage/connection lost */ -conn-alive = 0; -break; -} - -if (msg_type(msg) == sms conn-is_wap == 0) { -debug(bb.boxc, 0, boxc_receiver: sms received); + if (msg == NULL) { /* garbage/connection lost */ + conn-alive = 0; + break; + } -/* - * XXX save modifies ID, so if the smsbox uses it, save - * it FIRST for the reply message!!! - */ -store_save(msg); -if (smsc2_rout(msg)== -1) { -warning(0, Message rejected by bearerbox, no router!); -/* send NACK */ -bb_smscconn_send_failed(NULL, msg, SMSCCONN_FAILED_DISCARDED); -} -if (msg-sms.sms_type == mt_push) { -/* - * XXX generate ack-message and send it - in fact, this - * should include information did it succeed, wa sit queued - * or rejected... - */ -} + if (msg_type(msg) == sms conn-is_wap == 0) { + debug(bb.boxc, 0, boxc_receiver: sms received); + /* save modifies ID, so if the smsbox uses it, save + * it FIRST for the reply message!!! + * generate ack-message and send it - in fact, this + * should include information did it succeed, wa sit queued + * or rejected... + */ + mack = msg_create(ack); + mack-ack.id = msg-sms.id; + mack-ack.time = msg-sms.time; + store_save(msg); + rc = smsc2_rout(msg); + switch (rc) { + case -1: + warning(0, Message rejected by bearerbox, no router !); + /* send NACK */ + bb_smscconn_send_failed(NULL, msg, SMSCCONN_FAILED_DISCARDED); + mack-ack.nack = ack_failed; + break; + case -2: + warning(0, Message rejected by bearerbox, queue full !); + /* send NACK */ + bb_smscconn_send_failed(NULL, msg, SMSCCONN_FAILED_DISCARDED); + mack-ack.nack = ack_failed_tmp; + break; + case 0: + mack-ack.nack = ack_buffered; + break; + case 1: + mack-ack.nack = ack_success; + break; + } + list_produce(conn-incoming, mack); } else if (msg_type(msg) == wdp_datagram conn-is_wap) { debug(bb.boxc, 0, boxc_receiver: got wdp from wapbox); - + list_produce(conn-outgoing, msg); } else if (msg_type(msg) == sms conn-is_wap) { debug(bb.boxc, 0, boxc_receiver: got sms from wapbox); store_save(msg); -if (smsc2_rout(msg)== -1) { +if (smsc2_rout(msg) 0) { warning(0, Message rejected by bearerbox, no router!); msg_destroy(msg); } @@ -189,10 +204,10 @@ else if (msg_type(msg) == admin msg-admin.command == cmd_identify) { List *newlist; -/* and add the boxc_ud into conn for boxc_status() output */ +/* and add the boxc_id into conn for boxc_status() output */ if (conn-boxc_id == NULL) conn-boxc_id = octstr_duplicate(msg-admin.boxc_id); -/* +/* * re-link the incoming queue for this connection to an independent */ newlist = list_create(); @@ -200,7 +215,7 @@ conn-incoming = newlist; conn-retry = newlist; -
Re: [PATCH] avoid bearerbox oom-kill (fix)
Hi please re submit this patch as a unified diff, and ignoring changes to white space. This is horrid to read as there are many lines in the diff that are not necessary. nisan At 06:49 PM 11/15/02 +0100, Alexander Malysh wrote: Content-Type: text/plain; charset=iso-8859-15 X-MIME-Autoconverted: from 8bit to quoted-printable by mail-in-01.piro.net id SAA23798 Hi, this is the same oom-kill patch with memleak bugfix. -- Mit besten Grüßen aus Köln Dipl.-Ing. Alexander Malysh ___ Centrium GmbH Ehrenstraße 2 50672 Köln Fon: +49 (0221) 277 49 150 Fax: +49 (0221) 277 49 109 email: [EMAIL PROTECTED] web: www.centrium.de
Re: [PATCH] avoid bearerbox oom-kill (resend)
Hi, Am Freitag, 15. November 2002 19:00 schrieb Nisan Bloch: Hi please re submit this patch as a unified diff, and ignoring changes to white space. This is horrid to read as there are many lines in the diff that are not necessary. sorry for this ;) here is it ... nisan At 06:49 PM 11/15/02 +0100, Alexander Malysh wrote: Content-Type: text/plain; charset=iso-8859-15 X-MIME-Autoconverted: from 8bit to quoted-printable by mail-in-01.piro.net id SAA23798 Hi, this is the same oom-kill patch with memleak bugfix. -- Mit besten Grüßen aus Köln Dipl.-Ing. Alexander Malysh ___ Centrium GmbH Ehrenstraße 2 50672 Köln Fon: +49 (0221) 277 49 150 Fax: +49 (0221) 277 49 109 email: [EMAIL PROTECTED] web: www.centrium.de -- Mit besten Grüßen aus Köln Dipl.-Ing. Alexander Malysh ___ Centrium GmbH Ehrenstraße 2 50672 Köln Fon: +49 (0221) 277 49 150 Fax: +49 (0221) 277 49 109 email: [EMAIL PROTECTED] web: www.centrium.de Index: gw/bb_boxc.c === RCS file: /home/cvs/gateway/gw/bb_boxc.c,v retrieving revision 1.59 diff -a -u -b -r1.59 bb_boxc.c --- gw/bb_boxc.c 14 Nov 2002 02:29:25 - 1.59 +++ gw/bb_boxc.c 15 Nov 2002 18:37:00 - @@ -124,7 +124,8 @@ static void boxc_receiver(void *arg) { Boxc *conn = arg; -Msg *msg; +Msg *msg, *mack; +int rc; /* remove messages from socket until it is closed */ while (bb_status != BB_DEAD conn-alive) { @@ -141,24 +142,38 @@ if (msg_type(msg) == sms conn-is_wap == 0) { debug(bb.boxc, 0, boxc_receiver: sms received); -/* - * XXX save modifies ID, so if the smsbox uses it, save + /* save modifies ID, so if the smsbox uses it, save * it FIRST for the reply message!!! + * generate ack-message and send it - in fact, this + * should include information did it succeed, wa sit queued + * or rejected... */ + mack = msg_create(ack); + mack-ack.id = msg-sms.id; + mack-ack.time = msg-sms.time; store_save(msg); -if (smsc2_rout(msg)== -1) { -warning(0, Message rejected by bearerbox, no router!); + rc = smsc2_rout(msg); + switch (rc) { + case -1: + warning(0, Message rejected by bearerbox, no router !); /* send NACK */ bb_smscconn_send_failed(NULL, msg, SMSCCONN_FAILED_DISCARDED); + mack-ack.nack = ack_failed; + break; + case -2: + warning(0, Message rejected by bearerbox, queue full !); + /* send NACK */ + bb_smscconn_send_failed(NULL, msg, SMSCCONN_FAILED_DISCARDED); + mack-ack.nack = ack_failed_tmp; + break; + case 0: + mack-ack.nack = ack_buffered; + break; + case 1: + mack-ack.nack = ack_success; + break; } -if (msg-sms.sms_type == mt_push) { -/* - * XXX generate ack-message and send it - in fact, this - * should include information did it succeed, wa sit queued - * or rejected... - */ -} - + list_produce(conn-incoming, mack); } else if (msg_type(msg) == wdp_datagram conn-is_wap) { debug(bb.boxc, 0, boxc_receiver: got wdp from wapbox); @@ -168,7 +183,7 @@ debug(bb.boxc, 0, boxc_receiver: got sms from wapbox); store_save(msg); -if (smsc2_rout(msg)== -1) { +if (smsc2_rout(msg) 0) { warning(0, Message rejected by bearerbox, no router!); msg_destroy(msg); } @@ -189,7 +204,7 @@ else if (msg_type(msg) == admin msg-admin.command == cmd_identify) { List *newlist; -/* and add the boxc_ud into conn for boxc_status() output */ +/* and add the boxc_id into conn for boxc_status() output */ if (conn-boxc_id == NULL) conn-boxc_id = octstr_duplicate(msg-admin.boxc_id); /* Index: gw/bb_smscconn.c === RCS file: /home/cvs/gateway/gw/bb_smscconn.c,v retrieving revision 1.54 diff -a -u -b -r1.54 bb_smscconn.c --- gw/bb_smscconn.c 14 Nov 2002 02:29:25 - 1.54 +++ gw/bb_smscconn.c 15 Nov 2002 18:37:01 - @@ -175,7 +175,7 @@ } } -int bb_smscconn_receive(SMSCConn *conn, Msg *sms) +long bb_smscconn_receive(SMSCConn *conn, Msg *sms) { char *uf; @@ -193,13 +193,9 @@ warning(0, incoming messages queue too long, dropping a message); log_sms(conn, sms, DROPPED Received SMS); gwthread_sleep(0.1); /* letting the queue go down */ - return -1; +