1
0
Fork 0

mm1 speedups

This commit is contained in:
bagyenda 2008-12-24 19:00:30 +00:00
parent 2544b6d718
commit 967898a995
7 changed files with 47 additions and 31 deletions

View File

@ -1,3 +1,5 @@
2008-12-24 P. A. Bagyenda <bagyenda@dsmagic.com>
* Improved MM1 performance
2008-12-17 P. A. Bagyenda <bagyenda@dsmagic.com> 2008-12-17 P. A. Bagyenda <bagyenda@dsmagic.com>
* MM1 notify: increase parallelism * MM1 notify: increase parallelism
2008-12-10 P. A. Bagyenda <bagyenda@dsmagic.com> 2008-12-10 P. A. Bagyenda <bagyenda@dsmagic.com>

View File

@ -341,6 +341,7 @@ static int pgq_free_envelope(MmsEnvelope *e, int removefromqueue)
* v - vasid -- from VASP * v - vasid -- from VASP
* U - url1 -- e.g. for delivery report * U - url1 -- e.g. for delivery report
* u - url2 -- e.g. for read report * u - url2 -- e.g. for read report
* c - message class
* H - generic headers associated with message (e.g. for passing to MMC) * H - generic headers associated with message (e.g. for passing to MMC)
*/ */
@ -497,6 +498,9 @@ static MmsEnvelope *pgq_queue_readenvelope(char *qf, char *mms_queuedir, int sho
case 'I': case 'I':
e->msgId = octstr_create(res); e->msgId = octstr_create(res);
break; break;
case 'c':
e->mclass = octstr_create(res);
break;
case 'i': /* interface. */ case 'i': /* interface. */
strncpy(e->src_interface, res, sizeof e->src_interface); strncpy(e->src_interface, res, sizeof e->src_interface);
break; break;
@ -670,6 +674,9 @@ static int writeenvelope(MmsEnvelope *e, int newenv)
if (e->msgId) if (e->msgId)
_puthdr(qfs->conn, qfs->qid, "I", octstr_get_cstr(e->msgId)); _puthdr(qfs->conn, qfs->qid, "I", octstr_get_cstr(e->msgId));
if (e->mclass)
_puthdr(qfs->conn, qfs->qid, "c", octstr_get_cstr(e->mclass));
if (e->to) if (e->to)
n = gwlist_len(e->to); n = gwlist_len(e->to);
else else

View File

@ -1611,7 +1611,9 @@ MmsMsg *mms_deliveryreport(Octstr *msgid, Octstr *from, Octstr *to, time_t date,
return m; return m;
} }
MmsMsg *mms_notification(MmsMsg *msg, unsigned int msize, Octstr *url, MmsMsg *mms_notification(Octstr *from, Octstr *subject,
Octstr *mclass,
unsigned int msize, Octstr *url,
Octstr *transactionid, time_t expiryt, int optimizesize) Octstr *transactionid, time_t expiryt, int optimizesize)
{ {
MmsMsg *m = gw_malloc(sizeof *m); MmsMsg *m = gw_malloc(sizeof *m);
@ -1629,23 +1631,15 @@ MmsMsg *mms_notification(MmsMsg *msg, unsigned int msize, Octstr *url,
http_header_add(m->headers, "X-Mms-Transaction-ID", http_header_add(m->headers, "X-Mms-Transaction-ID",
octstr_get_cstr(transactionid)); octstr_get_cstr(transactionid));
http_header_add(m->headers, "X-Mms-MMS-Version", MMS_DEFAULT_VERSION); http_header_add(m->headers, "X-Mms-MMS-Version", MMS_DEFAULT_VERSION);
if (from)
http_header_add(m->headers, "From", octstr_get_cstr(from));
if (subject)
#define HX(h,d) do {\ http_header_add(m->headers, "Subject", octstr_get_cstr(subject));
Octstr *s = http_header_value(msg->headers, octstr_imm(#h)); \
if (s) { \ http_header_add(m->headers, "X-Mms-Message-Class",
http_header_add(m->headers, #h, octstr_get_cstr(s)); \ mclass ? octstr_get_cstr(mclass) : "Personal");
octstr_destroy(s); \
} else if (d) \
http_header_add(m->headers, #h, d); \
} while(0)
if (!optimizesize) {
HX(From,NULL);
HX(Subject,NULL);
}
HX(X-Mms-Message-Class, "Personal");
#undef HX
sprintf(buf, "%d", msize); sprintf(buf, "%d", msize);
http_header_add(m->headers, "X-Mms-Message-Size", buf); http_header_add(m->headers, "X-Mms-Message-Size", buf);

View File

@ -68,7 +68,8 @@ MmsMsg *mms_readreport(Octstr *msgid, Octstr *from, Octstr *to, time_t date, Oct
extern List *mms_message_headers(MmsMsg *msg); extern List *mms_message_headers(MmsMsg *msg);
/* Make a notification message out of this one and the url given. */ /* Make a notification message out of this one and the url given. */
extern MmsMsg *mms_notification(MmsMsg *msg, unsigned int msize, extern MmsMsg *mms_notification(Octstr *from, Octstr *subject,
Octstr *mclass, unsigned int msize,
Octstr *url, Octstr *url,
Octstr *transactionid, time_t expiryt, int optimizesize); Octstr *transactionid, time_t expiryt, int optimizesize);

View File

@ -130,6 +130,7 @@ static int free_envelope(MmsEnvelope *e, int removefromqueue);
* b - billed amount. * b - billed amount.
* r - whether delivery receipts are required or not. * r - whether delivery receipts are required or not.
* M - Application specific data (string) * M - Application specific data (string)
* c - Message Class
* V - VASPID -- from VASP * V - VASPID -- from VASP
* v - vasid -- from VASP * v - vasid -- from VASP
* U - url1 -- e.g. for delivery report * U - url1 -- e.g. for delivery report
@ -294,6 +295,9 @@ static MmsEnvelope *mms_queue_readenvelope(char *qf, char *mms_queuedir, int sho
case 'C': case 'C':
e->created = atol(res); e->created = atol(res);
break; break;
case 'c':
e->mclass = octstr_create(res);
break;
case 'L': case 'L':
e->lasttry = atol(res); e->lasttry = atol(res);
break; break;
@ -439,6 +443,9 @@ static int writeenvelope(MmsEnvelope *e, int newenv)
if (e->msgId) if (e->msgId)
_putline(fd, "I", octstr_get_cstr(e->msgId)); _putline(fd, "I", octstr_get_cstr(e->msgId));
if (e->mclass)
_putline(fd, "c", octstr_get_cstr(e->mclass));
if (e->src_interface[0]) if (e->src_interface[0])
_putline(fd, "i", e->src_interface); _putline(fd, "i", e->src_interface);
@ -827,6 +834,8 @@ void mms_queue_free_envelope(MmsEnvelope *e)
octstr_destroy(e->vasid); octstr_destroy(e->vasid);
octstr_destroy(e->url1); octstr_destroy(e->url1);
octstr_destroy(e->url2); octstr_destroy(e->url2);
octstr_destroy(e->mclass);
http_destroy_headers(e->hdrs); http_destroy_headers(e->hdrs);
gw_free(e); gw_free(e);
@ -850,7 +859,7 @@ MmsEnvelope *mms_queue_create_envelope(Octstr *from, List *to,
Octstr **binary_mms) Octstr **binary_mms)
{ {
MmsEnvelope *e; MmsEnvelope *e;
Octstr *msgid = NULL, *ms = NULL, *r, *xfrom; Octstr *msgid = NULL, *ms = NULL, *r, *xfrom, *mclass = NULL;
int mtype = -1, i, n; int mtype = -1, i, n;
if (m) { if (m) {
@ -863,6 +872,8 @@ MmsEnvelope *mms_queue_create_envelope(Octstr *from, List *to,
mms_replace_header_value(m, "Message-ID", octstr_get_cstr(msgid)); mms_replace_header_value(m, "Message-ID", octstr_get_cstr(msgid));
} }
ms = mms_tobinary(m); ms = mms_tobinary(m);
mclass = mms_get_header_value(m, octstr_imm("X-Mms-Message-Class"));
} }
xfrom = copy_and_clean_address(from); xfrom = copy_and_clean_address(from);
@ -890,7 +901,8 @@ MmsEnvelope *mms_queue_create_envelope(Octstr *from, List *to,
e->vasid = vasid ? octstr_duplicate(vasid) : NULL; e->vasid = vasid ? octstr_duplicate(vasid) : NULL;
e->url1 = url1 ? octstr_duplicate(url1) : NULL; e->url1 = url1 ? octstr_duplicate(url1) : NULL;
e->url2 = url2 ? octstr_duplicate(url2) : NULL; e->url2 = url2 ? octstr_duplicate(url2) : NULL;
e->hdrs = hdrs ? http_header_duplicate(hdrs) : NULL; e->hdrs = hdrs ? http_header_duplicate(hdrs) : http_create_empty_headers();
e->mclass = mclass;
e->dlr = dlr; e->dlr = dlr;
@ -913,6 +925,7 @@ MmsEnvelope *mms_queue_create_envelope(Octstr *from, List *to,
*binary_mms = ms; *binary_mms = ms;
else else
octstr_destroy(ms); octstr_destroy(ms);
return e; return e;
} }

View File

@ -32,7 +32,8 @@ typedef struct MmsEnvelope {
Octstr *msgId; /* message id (for reference). */ Octstr *msgId; /* message id (for reference). */
Octstr *token; /* User level token, may be null. */ Octstr *token; /* User level token, may be null. */
Octstr *from; /* from address. */ Octstr *from; /* from address. */
Octstr *mclass; /* Message class. */
Octstr *vaspid; /* VASPID (if any) */ Octstr *vaspid; /* VASPID (if any) */
Octstr *vasid; /* VASID (if any) */ Octstr *vasid; /* VASID (if any) */

View File

@ -38,9 +38,10 @@ static MmsEnvelope *update_env_success(MmsEnvelope *e, MmsEnvelopeTo *xto)
else else
e->sendt = e->lasttry + settings->send_back_off * e->attempts; e->sendt = e->lasttry + settings->send_back_off * e->attempts;
if (settings->qfs->mms_queue_update(e) == 1)
e = NULL;
} }
if (settings->qfs->mms_queue_update(e) == 1)
e = NULL;
return e; return e;
} }
@ -155,7 +156,7 @@ static void do_mm1_push(Octstr *rcpt_to, int isphonenum, MmsEnvelope *e, MmsMsg
static int sendNotify(MmsEnvelope *e) static int sendNotify(MmsEnvelope *e)
{ {
Octstr *to; Octstr *to;
MmsMsg *msg, *smsg = NULL; MmsMsg *smsg = NULL;
MmsEnvelopeTo *xto = gwlist_get(e->to, 0); MmsEnvelopeTo *xto = gwlist_get(e->to, 0);
Octstr *err = NULL; Octstr *err = NULL;
time_t tnow = time(NULL); time_t tnow = time(NULL);
@ -181,7 +182,6 @@ static int sendNotify(MmsEnvelope *e)
return 0; return 0;
} }
msg = settings->qfs->mms_queue_getdata(e);
to = octstr_duplicate(xto->rcpt); to = octstr_duplicate(xto->rcpt);
expiryt = e->expiryt; expiryt = e->expiryt;
msgId = e->msgId ? octstr_duplicate(e->msgId) : NULL; msgId = e->msgId ? octstr_duplicate(e->msgId) : NULL;
@ -189,6 +189,7 @@ static int sendNotify(MmsEnvelope *e)
fromproxy = e->fromproxy ? octstr_duplicate(e->fromproxy) : NULL; fromproxy = e->fromproxy ? octstr_duplicate(e->fromproxy) : NULL;
msize = e->msize; msize = e->msize;
dlr = e->dlr; dlr = e->dlr;
mtype = e->msgtype;
if (e->expiryt != 0 && /* Handle message expiry. */ if (e->expiryt != 0 && /* Handle message expiry. */
e->expiryt < tnow) { e->expiryt < tnow) {
@ -229,7 +230,6 @@ static int sendNotify(MmsEnvelope *e)
goto done; goto done;
} }
mtype = mms_messagetype(msg);
/* For phone, getting here means the message can be delivered. So: /* For phone, getting here means the message can be delivered. So:
* - Check whether the recipient is provisioned, if not, wait (script called will queue creation req) * - Check whether the recipient is provisioned, if not, wait (script called will queue creation req)
@ -312,7 +312,7 @@ static int sendNotify(MmsEnvelope *e)
octstr_get_cstr(url)); octstr_get_cstr(url));
transid = mms_maketransid(e->xqfname, settings->host_alias); transid = mms_maketransid(e->xqfname, settings->host_alias);
smsg = mms_notification(msg, e->msize, url, transid, smsg = mms_notification(e->from, e->subject, e->mclass, e->msize, url, transid,
e->expiryt ? e->expiryt : e->expiryt ? e->expiryt :
tnow + settings->default_msgexpiry, tnow + settings->default_msgexpiry,
settings->optimize_notification_size); settings->optimize_notification_size);
@ -320,7 +320,7 @@ static int sendNotify(MmsEnvelope *e)
octstr_destroy(url); octstr_destroy(url);
} else if (mtype == MMS_MSGTYPE_DELIVERY_IND || } else if (mtype == MMS_MSGTYPE_DELIVERY_IND ||
mtype == MMS_MSGTYPE_READ_ORIG_IND) mtype == MMS_MSGTYPE_READ_ORIG_IND)
smsg = msg; smsg = settings->qfs->mms_queue_getdata(e);
else { else {
mms_error(0, "MM1", NULL, "Unexpected message type %s for %s found in MT queue!", mms_error(0, "MM1", NULL, "Unexpected message type %s for %s found in MT queue!",
mms_message_type_to_cstr(mtype), octstr_get_cstr(to)); mms_message_type_to_cstr(mtype), octstr_get_cstr(to));
@ -335,7 +335,7 @@ static int sendNotify(MmsEnvelope *e)
e = NULL; e = NULL;
} }
if (smsg != msg && smsg) if (smsg)
mms_destroy(smsg); mms_destroy(smsg);
done: done:
@ -392,8 +392,6 @@ static int sendNotify(MmsEnvelope *e)
rtype ? rtype : "", rtype ? rtype : "",
e ? e->msgId : NULL, NULL, NULL); e ? e->msgId : NULL, NULL, NULL);
if (msg) mms_destroy(msg);
octstr_destroy(phonenum); octstr_destroy(phonenum);
octstr_destroy(rcpt_ip); octstr_destroy(rcpt_ip);