1
0
Fork 0

Added Fix from Jacek Raczkiewicz <jacek@skycore.com>

This commit is contained in:
bagyenda 2013-12-16 09:22:49 +00:00
parent 5208b4311f
commit be8dc0ee28
7 changed files with 86 additions and 5 deletions

View File

@ -1,3 +1,5 @@
2013-12-16 P. A. Bagyenda <bagyenda@dsmagic.com>
* Misc speed-ups and patches thanks to Jacek Raczkiewicz (jacek at skycore.com)
2012-04-10 P. A. Bagyenda <bagyenda@dsmagic.com>
* Added ability to receive carrier ID info via special HTTP header in SOAP request to mmsbox (a la OpenMarket)
2011-10-11 P. A. Bagyenda <bagyenda@dsmagic.com>

View File

@ -3257,7 +3257,22 @@ string
in a <tt>X-Mbuni-CarrierID</tt> header.
</td>
</tr>
1
<tr>
<td valign=top >
<tt>retry-statuses
</tt>
&nbsp; &nbsp;</td>
<td valign=top >
String
</td>
<td valign=top >
Optional. Semicolon separated list of HTTP and MM7 statuses that makes MBUNI to retry sending to MMSC.
MM7 statuses are checked only when HTTP 200 is received from MMSC (HTTP 200 is always assumed as retry status).</td>
</tr>
</table>

View File

@ -1166,7 +1166,7 @@ static void pgdeliver(struct PGDeliverData_t *pgdata)
/* we're done, exit. */
mms_info(0, "pgdeliver", NULL, "Shutdown on queue [%s]", pgdata->dir);
}
#define MAX_QLEN 10 /* we don't allow more than this number pending per thread. */
#define MAX_QLEN 10000 /* we don't allow more than this number pending per thread. */
static void pgq_queue_run(char *dir,
int (*deliver)(MmsEnvelope *),
double sleepsecs, int num_threads, volatile sig_atomic_t *rstop)

View File

@ -198,6 +198,7 @@ MULTI_GROUP(mmsc,
OCTSTR(max-recipients)
OCTSTR(strip-prefixes)
OCTSTR(retry-statuses)
OCTSTR(mm1-http-proxy)
OCTSTR(mm1-gprs-on-command)
OCTSTR(mm1-gprs-off-command)

View File

@ -1112,6 +1112,30 @@ void mmsc_receive_func(MmscGrp *m)
}
/* This function check if there is custom retry statuses list setup for mmc,
* if not it returns -1,
* if it is set check if current status should be retried (returns 1) or not (returns 0)
*/
int check_custom_retry_statuses(MmscGrp *mmc, int hstatus) {
int retry_sending = -1, i, n;
Octstr *res_str = octstr_format("%d", hstatus);
if (mmc && mmc->retry_statuses != NULL) {
retry_sending = 0;
for (i = 0, n = gwlist_len(mmc->retry_statuses); i<n; i++) {
Octstr *retry_status = gwlist_get(mmc->retry_statuses, i);
if (octstr_compare(res_str, retry_status) == 0) {
retry_sending = 1;
break;
}
}
}
octstr_destroy(res_str);
return retry_sending;
}
/* XXX Returns msgid in mmsc or NULL if error. Caller uses this for DLR issues.
* Caller must make sure throughput issues
* are observed!
@ -1137,6 +1161,7 @@ static Octstr *mm7soap_send(MmscGrp *mmc, Octstr *from, List *lto,
Octstr *s, *r, *status_details = NULL;
char *xvasid = vasid ? vasid : (mmc->default_vasid ? octstr_get_cstr(mmc->default_vasid) : NULL);
Octstr *to;
int retry_sending = -1;
LINEARISE_STR_LIST(to,lto,", ");
@ -1173,6 +1198,10 @@ static Octstr *mm7soap_send(MmscGrp *mmc, Octstr *from, List *lto,
mmc->mmsc_url, hstatus);
if (hstatus < 0)
MMSC_ISSUE_ALARM(mmc, MMSBOX_ALARM_SOCKET_CONNECT_FAILED, 3);
/* Now check if we should retry */
retry_sending = check_custom_retry_statuses(mmc, hstatus);
MMSC_ISSUE_ALARM(mmc, MMSBOX_ALARM_MM7_NON_200_RESULT, 3);
goto done1;
} else {
@ -1227,6 +1256,9 @@ static Octstr *mm7soap_send(MmscGrp *mmc, Octstr *from, List *lto,
tstatus = MM7_SOAP_FORMAT_CORRUPT;
}
/* Now check if we should retry */
retry_sending = check_custom_retry_statuses(mmc, tstatus);
if (!MM7_SOAP_STATUS_OK(tstatus) && tstatus != MM7_SOAP_COMMAND_REJECTED) {
char *tmp = (char *)mms_soap_status_to_cstr(tstatus);
@ -1263,7 +1295,10 @@ static Octstr *mm7soap_send(MmscGrp *mmc, Octstr *from, List *lto,
if (ret)
mms_log2("Sent", from, to, -1, ret, NULL, mmc->id, "MMSBox", NULL, NULL);
done1:
*retry = (ret == NULL && (!MM7_SOAP_CLIENT_ERROR(tstatus) || tstatus < 0));
//DEFAULT when retry_sending < 0
//otherwise we rely on retry_status list
if (retry_sending < 0) *retry = (ret == NULL && (!MM7_SOAP_CLIENT_ERROR(tstatus) || tstatus < 0));
else *retry = retry_sending;
mm7_soap_destroy(mreq);
mm7_soap_destroy(mresp);
@ -1295,6 +1330,7 @@ static Octstr *mm7eaif_send(MmscGrp *mmc, Octstr *from, List *lto,
MmsMsg *mresp = NULL;
int mresp_type = -1, i;
Octstr *to;
int retry_sending = -1;
LINEARISE_STR_LIST(to,lto,", ");
@ -1351,6 +1387,10 @@ static Octstr *mm7eaif_send(MmscGrp *mmc, Octstr *from, List *lto,
mmc->mmsc_url, hstatus);
if (hstatus < 0)
MMSC_ISSUE_ALARM(mmc, MMSBOX_ALARM_SOCKET_CONNECT_FAILED, 3);
/* Now check if we should retry */
retry_sending = check_custom_retry_statuses(mmc, hstatus);
MMSC_ISSUE_ALARM(mmc, MMSBOX_ALARM_MM7_NON_200_RESULT, 3);
} else {
MMSC_CLEAR_ALARM(mmc, MMSBOX_ALARM_MM7_NON_200_RESULT);
@ -1377,7 +1417,11 @@ static Octstr *mm7eaif_send(MmscGrp *mmc, Octstr *from, List *lto,
else if (!ret)
ret = http_header_value(ph, octstr_imm("X-Nokia-MMSC-Message-Id"));
}
*retry = (ret == NULL && (hstatus == HTTP_STATUS_SERVER_ERROR || hstatus < 0));
//DEFAULT when retry_sending < 0
//otherwise we rely on retry_status list
if (retry_sending < 0) *retry = (ret == NULL && (hstatus == HTTP_STATUS_SERVER_ERROR || hstatus < 0));
else *retry = retry_sending;
mmsbox_event_cb(mmc->id,
mm7_msgtype_to_soaptype(mresp_type,1), 0, xver, hstatus,
@ -1423,6 +1467,7 @@ static Octstr *mm7http_send(MmscGrp *mmc,
Octstr *transid = e ? octstr_create(e->xqfname) : NULL;
int mm7type = mm7_msgtype_to_soaptype(mtype,1);
Octstr *to;
int retry_sending = -1;
LINEARISE_STR_LIST(to,lto," ");
@ -1453,6 +1498,10 @@ static Octstr *mm7http_send(MmscGrp *mmc,
mmc->mmsc_url, hstatus);
if (hstatus < 0)
MMSC_ISSUE_ALARM(mmc, MMSBOX_ALARM_SOCKET_CONNECT_FAILED, 3);
/* Now check if we should retry */
retry_sending = check_custom_retry_statuses(mmc, hstatus);
MMSC_ISSUE_ALARM(mmc, MMSBOX_ALARM_MM7_NON_200_RESULT, 3);
} else {
ret = rbody ? octstr_duplicate(rbody) : NULL;
@ -1467,7 +1516,10 @@ static Octstr *mm7http_send(MmscGrp *mmc,
0, e->attempts, e->from,
to, ret, transid, hdrs, NULL);
*retry = (ret == NULL && (http_status_class(hstatus) == HTTP_STATUS_SERVER_ERROR || hstatus < 0));
//DEFAULT when retry_sending < 0
//otherwise we rely on retry_status list
if (retry_sending < 0) *retry = (ret == NULL && (http_status_class(hstatus) == HTTP_STATUS_SERVER_ERROR || hstatus < 0));
else *retry = retry_sending;
if (ret)
mms_log2("Sent", from, to, -1, ret, NULL, mmc->id, "MMSBox", NULL, NULL);

View File

@ -636,6 +636,14 @@ static MmscGrp *start_mmsc_from_conf(mCfg *cfg, mCfgGrp *x, List *warnings, List
} else
m->strip_prefixes = NULL;
if ((s = mms_cfg_get(cfg, x, octstr_imm("retry-statuses"))) != NULL) {
m->retry_statuses = octstr_split(s, octstr_imm(";"));
octstr_destroy(s);
} else
m->retry_statuses = NULL;
if (mms_cfg_get_int(cfg,x, octstr_imm("maximum-request-size"), &m->max_pkt_size) < 0 ||
m->max_pkt_size <= 0)
m->max_pkt_size = DEFAULT_MAX_PKT_SIZE;
@ -1299,6 +1307,7 @@ static void free_mmsc_struct (MmscGrp *m)
octstr_destroy(m->settings);
mutex_destroy(m->mutex);
gwlist_destroy(m->strip_prefixes, (void *)octstr_destroy);
gwlist_destroy(m->retry_statuses, (void *)octstr_destroy);
octstr_destroy(m->mm1.proxy);
octstr_destroy(m->mm1.gprs_on);

View File

@ -89,6 +89,8 @@ typedef struct MmscGrp {
List *strip_prefixes; /* List of prefixes to be stripped before sending out*/
List *retry_statuses; /* List of HTTP/MM7 statuses we do retry on, MM7 statuses are checked only on HTTP 200 - they do not overlap*/
struct MM1Info_t { /* Stuff used only by the MM1 MMSC */
Octstr *proxy; /* Proxy within the operator network, form of host:port */
Octstr *gprs_on; /* Command to start GPRS link. Must not exit. */