Re: [PATCH] more precise throughput using double [v3]
Alexander Malysh <[email protected]>
| Newsgroups | gmane.comp.mobile.kannel.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi, +1 from me. Thanks, Alex Vincent CHAVANIS schrieb: > errata on condition > > - if (throughput == ERANGE && throughput <= 0) > + if (throughput == ERANGE || throughput <= 0) > > regards > > Vincent. > > -- > Telemaque - NICE - (FR) > Service Technique - Developpement > http://www.telemaque.fr/ > [email protected] > Tel : +33 4 93 97 71 64 (fax 68) > > > ------------------------------------------------------------------------ > > diff -ru /gateway/gw/smsc/smsc_emi.c /gateway2/gw/smsc/smsc_emi.c > --- /gateway/gw/smsc/smsc_emi.c 2005-02-11 16:35:48.000000000 +0100 > +++ /gateway2/gw/smsc/smsc_emi.c 2006-03-06 13:58:42.000000000 +0100 > @@ -992,7 +1006,7 @@ > Msg *msg; > double delay = 0; > > - if (conn->throughput) { > + if (conn->throughput > 0) { > delay = 1.0 / conn->throughput; > } > > @@ -1001,7 +1015,7 @@ > (msg = gw_prioqueue_remove(PRIVDATA(conn)->outgoing_queue)) != NULL) { > int nexttrn = emi2_next_trn(conn); > > - if (conn->throughput) > + if (conn->throughput > 0) > gwthread_sleep(delay); > > /* convert the generic Kannel message into an EMI type message */ > diff -ru /gateway/gw/smsc/smsc_fake.c /gateway2/gw/smsc/smsc_fake.c > --- /gateway/gw/smsc/smsc_fake.c 2005-02-11 16:35:48.000000000 +0100 > +++ /gateway2/gw/smsc/smsc_fake.c 2006-03-06 14:03:37.000000000 +0100 > @@ -243,10 +243,12 @@ > Msg *msg; > double delay = 0; > > - if (conn->throughput) { > + if (conn->throughput > 0) { > delay = 1.0 / conn->throughput; > } > > while (1) { > while (!conn->is_stopped && !privdata->shutdown && > (line = conn_read_line(client))) > @@ -297,7 +299,7 @@ > } > > /* obey throughput speed limit, if any */ > - if (conn->throughput) { > + if (conn->throughput > 0) { > gwthread_sleep(delay); > } > } > diff -ru /gateway/gw/smsc/smsc_http.c /gateway2/gw/smsc/smsc_http.c > --- /gateway/gw/smsc/smsc_http.c 2005-09-20 00:07:33.000000000 +0200 > +++ /gateway2/gw/smsc/smsc_http.c 2006-03-06 14:02:58.000000000 +0100 > @@ -1072,7 +1072,7 @@ > Msg *sms = msg_duplicate(msg); > double delay = 0; > > - if (conn->throughput) { > + if (conn->throughput > 0) { > delay = 1.0 / conn->throughput; > } > > @@ -1080,7 +1080,7 @@ > conndata->send_sms(conn, sms); > > /* obey throughput speed limit, if any */ > - if (conn->throughput) > + if (conn->throughput > 0) > gwthread_sleep(delay); > > return 0; > diff -ru /gateway/gw/smsc/smsc_smasi.c /gateway2/gw/smsc/smsc_smasi.c > --- /gateway/gw/smsc/smsc_smasi.c 2005-02-11 16:35:48.000000000 +0100 > +++ /gateway2/gw/smsc/smsc_smasi.c 2006-03-06 14:03:12.000000000 +0100 > @@ -872,7 +872,7 @@ > > if (*pending_submits == -1) return; > > - if (smasi->conn->throughput) { > + if (smasi->conn->throughput > 0) { > delay = 1.0 / smasi->conn->throughput; > } > > @@ -894,7 +894,7 @@ > smasi_pdu_destroy(pdu); > > /* obey throughput speed limit, if any */ > - if (smasi->conn->throughput) > + if (smasi->conn->throughput > 0) > gwthread_sleep(delay); > > ++(*pending_submits); > diff -ru /gateway/gw/smsc/smsc_smpp.c /gateway2/gw/smsc/smsc_smpp.c > --- /gateway/gw/smsc/smsc_smpp.c 2006-02-07 15:54:44.000000000 +0100 > +++ /gateway2/gw/smsc/smsc_smpp.c 2006-03-06 14:02:27.000000000 +0100 > @@ -1013,7 +1013,7 @@ > /* > * obey throughput speed limit, if any. > */ > - if (smpp->conn->throughput) > + if (smpp->conn->throughput > 0) > gwthread_sleep(delay); > } > else { /* write error occurs */ > diff -ru /gateway/gw/smscconn.c /gateway2/gw/smscconn.c > --- /gateway/gw/smscconn.c 2005-03-09 21:04:20.000000000 +0100 > +++ /gateway2/gw/smscconn.c 2006-03-06 14:23:15.000000000 +0100 > @@ -64,6 +64,7 @@ > > #include <signal.h> > #include <time.h> > +#include <errno.h> > > #include "gwlib/gwlib.h" > #include "gwlib/regex.h" > @@ -151,7 +152,7 @@ > SMSCConn *conn; > Octstr *smsc_type; > int ret; > - long throughput; > + double throughput; > Octstr *allowed_smsc_id_regex; > Octstr *denied_smsc_id_regex; > Octstr *allowed_prefix_regex; > @@ -216,10 +217,14 @@ > if ((conn->preferred_prefix_regex = gw_regex_comp(preferred_prefix_regex, REG_EXTENDED)) == NULL) > panic(0, "Could not compile pattern '%s'", octstr_get_cstr(preferred_prefix_regex)); > > - if (cfg_get_integer(&throughput, grp, octstr_imm("throughput")) == -1) > + throughput = strtod(octstr_get_cstr(cfg_get(grp, octstr_imm("throughput"))),(char **) NULL); > + > + if (throughput == ERANGE || throughput <= 0) > conn->throughput = 0; /* defaults to no throughtput limitation */ > else > - conn->throughput = (int) throughput; > + conn->throughput = throughput; > + > + info(0, "Set throughput to %.3f for smsc id <%s>", throughput, octstr_get_cstr(conn->id)); > > /* configure the internal rerouting rules for this smsc id */ > init_reroute(conn, grp); > diff -ru /gateway/gw/smscconn_p.h /gateway2/gw/smscconn_p.h > --- /gateway/gw/smscconn_p.h 2005-02-11 16:35:48.000000000 +0100 > +++ /gateway2/gw/smscconn_p.h 2006-03-06 14:22:53.000000000 +0100 > @@ -194,7 +194,7 @@ > > int alt_dcs; /* use alternate DCS 0xFX */ > > - int throughput; /* message thoughput per sec. to be delivered to SMSC */ > + double throughput; /* message thoughput per sec. to be delivered to SMSC */ > > /* Stores rerouting information for this specific smsc-id */ > int reroute; /* simply turn MO into MT and process internally */