The issue is located on the mtbatch program that exit before receiving all
ack/nack from bearerbox.
(btw, Thanks to alex pointing me this)
The result is an TCP broken pipe System error 104: Connection reset by peer
This patch fixes this.
Vincent.
--
Telemaque - 06560 SOPHIA-ANTIPOLIS - (FR)
Service Technique/Reseau - NOC
Direction du Developpement xMS+
http://www.telemaque.fr/
[email protected]
Tel : +33 4 92 90 99 84 (fax 9142)
--- /operateurs/cvsroot/gateway/utils/mtbatch.c 2009-01-14 10:24:23.000000000
+0100
+++ mtbatch.c 2009-03-27 18:05:08.000000000 +0100
@@ -87,6 +87,7 @@
static Octstr *bb_host;
static long bb_port;
static int bb_ssl;
+static volatile unsigned long backed = 0;
static Octstr *service = NULL;
static Octstr *account = NULL;
static Octstr *from = NULL;
@@ -135,10 +136,10 @@
{
time_t start, t;
unsigned long secs;
- unsigned long total_s, total_f, total_ft, total_b;
+ unsigned long total_s, total_f, total_ft, total_b, total_o;
Msg *msg;
- total_s = total_f = total_ft = total_b = 0;
+ total_s = total_f = total_ft = total_b = total_o = 0;
start = t = time(NULL);
while (program_status != shutting_down) {
int ret;
@@ -162,6 +163,7 @@
*/
msg_destroy(msg);
} else if (msg_type(msg) == ack) {
+ backed++;
switch (msg->ack.nack) {
case ack_success:
total_s++;
@@ -178,13 +180,14 @@
}
msg_destroy(msg);
} else {
- warning(0, "Received other message than sms/admin, ignoring!");
+ warning(0, "Received other message than ack/admin, ignoring!");
msg_destroy(msg);
+ total_o++;
}
}
secs = difftime(time(NULL), start);
- info(0, "Received acks: %ld success, %ld failed, %ld failed temporarly,
%ld queued in %ld seconds "
- "(%.2f per second)", total_s, total_f, total_ft, total_b, secs,
+ info(0, "Received acks: %ld success, %ld failed, %ld failed temporarly,
%ld queued, %ld other in %.2f seconds "
+ "(%.2f per second)", total_s, total_f, total_ft, total_b, total_o,
(float) secs,
(float)(total_s+total_f+total_ft+total_b) / secs);
}
@@ -262,7 +265,7 @@
static void init_batch(Octstr *cfilename, Octstr *rfilename)
{
Octstr *receivers;
- long lineno = 0;
+ unsigned long lineno = 0;
content = octstr_read_file(octstr_get_cstr(cfilename));
octstr_strip_crlfs(content);
@@ -286,10 +289,12 @@
octstr_get_cstr(rfilename), lineno);
}
-static void run_batch(void)
+int run_batch(void)
{
Octstr *no;
+ unsigned long linerr = 0;
unsigned long lineno = 0;
+ int r = 0;
while ((no = gwlist_consume(lines)) != NULL) {
if (octstr_check_range(no, 0, 256, gw_isdigit)) {
@@ -310,6 +315,7 @@
msg->sms.coding = DC_7BIT;
if (send_message(msg) < 0) {
+ linerr++;
panic(0,"Failed to send message at line <%ld> for receiver `%s' to
bearerbox.",
lineno, octstr_get_cstr(no));
}
@@ -317,18 +324,21 @@
octstr_destroy(no);
}
}
+ info(0,"mtbatch has processed %ld messages with %ld errors", lineno,
linerr);
+ return lineno;
}
int main(int argc, char **argv)
{
int opt;
+ unsigned long sended;
Octstr *cf, *rf;
gwlib_init();
bb_host = octstr_create("localhost");
bb_port = 13001;
- bb_ssl = 0;
+ bb_ssl = sended = 0;
while ((opt = getopt(argc, argv, "hv:b:p:si:n:a:f:d:r:")) != EOF) {
switch (opt) {
@@ -392,7 +402,9 @@
identify_to_bearerbox();
gwthread_create(read_messages_from_bearerbox, NULL);
- run_batch();
+ sended = run_batch();
+
+ while(backed < sended) { /* avoid exiting before sending all msgs */ }
program_status = shutting_down;
gwthread_join_all();