mm1 speedups
This commit is contained in:
parent
2544b6d718
commit
967898a995
|
@ -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>
|
||||
* MM1 notify: increase parallelism
|
||||
2008-12-10 P. A. Bagyenda <bagyenda@dsmagic.com>
|
||||
|
|
|
@ -341,6 +341,7 @@ static int pgq_free_envelope(MmsEnvelope *e, int removefromqueue)
|
|||
* v - vasid -- from VASP
|
||||
* U - url1 -- e.g. for delivery report
|
||||
* u - url2 -- e.g. for read report
|
||||
* c - message class
|
||||
* 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':
|
||||
e->msgId = octstr_create(res);
|
||||
break;
|
||||
case 'c':
|
||||
e->mclass = octstr_create(res);
|
||||
break;
|
||||
case 'i': /* interface. */
|
||||
strncpy(e->src_interface, res, sizeof e->src_interface);
|
||||
break;
|
||||
|
@ -670,6 +674,9 @@ static int writeenvelope(MmsEnvelope *e, int newenv)
|
|||
if (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)
|
||||
n = gwlist_len(e->to);
|
||||
else
|
||||
|
|
|
@ -1611,7 +1611,9 @@ MmsMsg *mms_deliveryreport(Octstr *msgid, Octstr *from, Octstr *to, time_t date,
|
|||
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)
|
||||
{
|
||||
MmsMsg *m = gw_malloc(sizeof *m);
|
||||
|
@ -1630,22 +1632,14 @@ MmsMsg *mms_notification(MmsMsg *msg, unsigned int msize, Octstr *url,
|
|||
octstr_get_cstr(transactionid));
|
||||
http_header_add(m->headers, "X-Mms-MMS-Version", MMS_DEFAULT_VERSION);
|
||||
|
||||
if (from)
|
||||
http_header_add(m->headers, "From", octstr_get_cstr(from));
|
||||
|
||||
#define HX(h,d) do {\
|
||||
Octstr *s = http_header_value(msg->headers, octstr_imm(#h)); \
|
||||
if (s) { \
|
||||
http_header_add(m->headers, #h, octstr_get_cstr(s)); \
|
||||
octstr_destroy(s); \
|
||||
} else if (d) \
|
||||
http_header_add(m->headers, #h, d); \
|
||||
} while(0)
|
||||
if (subject)
|
||||
http_header_add(m->headers, "Subject", octstr_get_cstr(subject));
|
||||
|
||||
if (!optimizesize) {
|
||||
HX(From,NULL);
|
||||
HX(Subject,NULL);
|
||||
}
|
||||
HX(X-Mms-Message-Class, "Personal");
|
||||
#undef HX
|
||||
http_header_add(m->headers, "X-Mms-Message-Class",
|
||||
mclass ? octstr_get_cstr(mclass) : "Personal");
|
||||
|
||||
sprintf(buf, "%d", msize);
|
||||
http_header_add(m->headers, "X-Mms-Message-Size", buf);
|
||||
|
|
|
@ -68,7 +68,8 @@ MmsMsg *mms_readreport(Octstr *msgid, Octstr *from, Octstr *to, time_t date, Oct
|
|||
extern List *mms_message_headers(MmsMsg *msg);
|
||||
|
||||
/* 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 *transactionid, time_t expiryt, int optimizesize);
|
||||
|
||||
|
|
|
@ -130,6 +130,7 @@ static int free_envelope(MmsEnvelope *e, int removefromqueue);
|
|||
* b - billed amount.
|
||||
* r - whether delivery receipts are required or not.
|
||||
* M - Application specific data (string)
|
||||
* c - Message Class
|
||||
* V - VASPID -- from VASP
|
||||
* v - vasid -- from VASP
|
||||
* 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':
|
||||
e->created = atol(res);
|
||||
break;
|
||||
case 'c':
|
||||
e->mclass = octstr_create(res);
|
||||
break;
|
||||
case 'L':
|
||||
e->lasttry = atol(res);
|
||||
break;
|
||||
|
@ -439,6 +443,9 @@ static int writeenvelope(MmsEnvelope *e, int newenv)
|
|||
if (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])
|
||||
_putline(fd, "i", e->src_interface);
|
||||
|
||||
|
@ -827,6 +834,8 @@ void mms_queue_free_envelope(MmsEnvelope *e)
|
|||
octstr_destroy(e->vasid);
|
||||
octstr_destroy(e->url1);
|
||||
octstr_destroy(e->url2);
|
||||
octstr_destroy(e->mclass);
|
||||
|
||||
http_destroy_headers(e->hdrs);
|
||||
|
||||
gw_free(e);
|
||||
|
@ -850,7 +859,7 @@ MmsEnvelope *mms_queue_create_envelope(Octstr *from, List *to,
|
|||
Octstr **binary_mms)
|
||||
{
|
||||
MmsEnvelope *e;
|
||||
Octstr *msgid = NULL, *ms = NULL, *r, *xfrom;
|
||||
Octstr *msgid = NULL, *ms = NULL, *r, *xfrom, *mclass = NULL;
|
||||
int mtype = -1, i, n;
|
||||
|
||||
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));
|
||||
}
|
||||
ms = mms_tobinary(m);
|
||||
|
||||
mclass = mms_get_header_value(m, octstr_imm("X-Mms-Message-Class"));
|
||||
}
|
||||
|
||||
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->url1 = url1 ? octstr_duplicate(url1) : 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;
|
||||
|
@ -913,6 +925,7 @@ MmsEnvelope *mms_queue_create_envelope(Octstr *from, List *to,
|
|||
*binary_mms = ms;
|
||||
else
|
||||
octstr_destroy(ms);
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ typedef struct MmsEnvelope {
|
|||
Octstr *msgId; /* message id (for reference). */
|
||||
Octstr *token; /* User level token, may be null. */
|
||||
Octstr *from; /* from address. */
|
||||
Octstr *mclass; /* Message class. */
|
||||
|
||||
Octstr *vaspid; /* VASPID (if any) */
|
||||
Octstr *vasid; /* VASID (if any) */
|
||||
|
|
|
@ -38,9 +38,10 @@ static MmsEnvelope *update_env_success(MmsEnvelope *e, MmsEnvelopeTo *xto)
|
|||
else
|
||||
e->sendt = e->lasttry + settings->send_back_off * e->attempts;
|
||||
|
||||
}
|
||||
|
||||
if (settings->qfs->mms_queue_update(e) == 1)
|
||||
e = NULL;
|
||||
}
|
||||
|
||||
return e;
|
||||
}
|
||||
|
@ -155,7 +156,7 @@ static void do_mm1_push(Octstr *rcpt_to, int isphonenum, MmsEnvelope *e, MmsMsg
|
|||
static int sendNotify(MmsEnvelope *e)
|
||||
{
|
||||
Octstr *to;
|
||||
MmsMsg *msg, *smsg = NULL;
|
||||
MmsMsg *smsg = NULL;
|
||||
MmsEnvelopeTo *xto = gwlist_get(e->to, 0);
|
||||
Octstr *err = NULL;
|
||||
time_t tnow = time(NULL);
|
||||
|
@ -181,7 +182,6 @@ static int sendNotify(MmsEnvelope *e)
|
|||
return 0;
|
||||
}
|
||||
|
||||
msg = settings->qfs->mms_queue_getdata(e);
|
||||
to = octstr_duplicate(xto->rcpt);
|
||||
expiryt = e->expiryt;
|
||||
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;
|
||||
msize = e->msize;
|
||||
dlr = e->dlr;
|
||||
mtype = e->msgtype;
|
||||
|
||||
if (e->expiryt != 0 && /* Handle message expiry. */
|
||||
e->expiryt < tnow) {
|
||||
|
@ -229,7 +230,6 @@ static int sendNotify(MmsEnvelope *e)
|
|||
goto done;
|
||||
}
|
||||
|
||||
mtype = mms_messagetype(msg);
|
||||
|
||||
/* 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)
|
||||
|
@ -312,7 +312,7 @@ static int sendNotify(MmsEnvelope *e)
|
|||
octstr_get_cstr(url));
|
||||
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 :
|
||||
tnow + settings->default_msgexpiry,
|
||||
settings->optimize_notification_size);
|
||||
|
@ -320,7 +320,7 @@ static int sendNotify(MmsEnvelope *e)
|
|||
octstr_destroy(url);
|
||||
} else if (mtype == MMS_MSGTYPE_DELIVERY_IND ||
|
||||
mtype == MMS_MSGTYPE_READ_ORIG_IND)
|
||||
smsg = msg;
|
||||
smsg = settings->qfs->mms_queue_getdata(e);
|
||||
else {
|
||||
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));
|
||||
|
@ -335,7 +335,7 @@ static int sendNotify(MmsEnvelope *e)
|
|||
e = NULL;
|
||||
}
|
||||
|
||||
if (smsg != msg && smsg)
|
||||
if (smsg)
|
||||
mms_destroy(smsg);
|
||||
|
||||
done:
|
||||
|
@ -392,8 +392,6 @@ static int sendNotify(MmsEnvelope *e)
|
|||
rtype ? rtype : "",
|
||||
e ? e->msgId : NULL, NULL, NULL);
|
||||
|
||||
if (msg) mms_destroy(msg);
|
||||
|
||||
octstr_destroy(phonenum);
|
||||
|
||||
octstr_destroy(rcpt_ip);
|
||||
|
|
Loading…
Reference in New Issue