misc bug fixes
This commit is contained in:
parent
fd2ed9038f
commit
60be3311ca
|
@ -1,3 +1,5 @@
|
||||||
|
2010-10-26 P. A. Bagyenda <bagyenda@dsmagic.com>
|
||||||
|
* Misc bug fixes
|
||||||
2010-10-25 P. A. Bagyenda <bagyenda@dsmagic.com>
|
2010-10-25 P. A. Bagyenda <bagyenda@dsmagic.com>
|
||||||
* Added MM4 incoming handler for mmsbox
|
* Added MM4 incoming handler for mmsbox
|
||||||
2010-10-22 P. A. Bagyenda <bagyenda@dsmagic.com>
|
2010-10-22 P. A. Bagyenda <bagyenda@dsmagic.com>
|
||||||
|
|
|
@ -78,11 +78,11 @@ case "$host" in
|
||||||
EXE_EXT=".exe"
|
EXE_EXT=".exe"
|
||||||
;;
|
;;
|
||||||
*apple-darwin*)
|
*apple-darwin*)
|
||||||
CFLAGS="$CFLAGS -DDARWIN=1 -O4 -Wall"
|
CFLAGS="$CFLAGS -DDARWIN=1 -O4 -Wall -D_REENTRANT=1"
|
||||||
LIB_EXT="dylib"
|
LIB_EXT="dylib"
|
||||||
;;
|
;;
|
||||||
*-linux*)
|
*-linux*)
|
||||||
CFLAGS="$CFLAGS -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -O4 -Wall"
|
CFLAGS="$CFLAGS -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -O4 -Walli -D_REENTRANT=1"
|
||||||
LDFLAGS="$LDFLAGS -rdynamic"
|
LDFLAGS="$LDFLAGS -rdynamic"
|
||||||
;;
|
;;
|
||||||
*-*-openbsd*)
|
*-*-openbsd*)
|
||||||
|
|
|
@ -534,9 +534,13 @@ static int send2email(Octstr *to, Octstr *from, Octstr *subject,
|
||||||
Octstr *s;
|
Octstr *s;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
int ret = MMS_SEND_OK, i, n;
|
int ret = MMS_SEND_OK, i, n;
|
||||||
|
char fname[L_tmpnam];
|
||||||
|
|
||||||
Octstr *cmd = octstr_create("");
|
Octstr *cmd = octstr_create("");
|
||||||
List *headers = mime_entity_headers(m); /* we don't want the mime version header removed. */
|
List *headers = mime_entity_headers(m); /* we don't want the mime version header removed. */
|
||||||
|
|
||||||
|
fname[0] = 0;
|
||||||
|
|
||||||
if (append_hostname) { /* Add our hostname to all phone numbers. */
|
if (append_hostname) { /* Add our hostname to all phone numbers. */
|
||||||
List *l = http_create_empty_headers();
|
List *l = http_create_empty_headers();
|
||||||
Octstr *xfrom = http_header_value(headers, octstr_imm("From"));
|
Octstr *xfrom = http_header_value(headers, octstr_imm("From"));
|
||||||
|
@ -661,33 +665,44 @@ static int send2email(Octstr *to, Octstr *from, Octstr *subject,
|
||||||
}
|
}
|
||||||
i += 2;
|
i += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
debug("mms.sendtoemail", 0, "preparing to execute %s to send to email: ", octstr_get_cstr(cmd));
|
|
||||||
|
|
||||||
if ((f = popen(octstr_get_cstr(cmd), "w")) == NULL) {
|
if (tmpnam(fname) == NULL) {
|
||||||
*error = octstr_format("popen failed for %S: %d: %s",
|
*error = octstr_format("tmpnam: Failed to create temporary file: %s",
|
||||||
cmd, errno, strerror(errno));
|
strerror(errno));
|
||||||
ret = MMS_SEND_ERROR_TRANSIENT;
|
ret = MMS_SEND_ERROR_TRANSIENT;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
if ((f = fopen(fname, "w")) == NULL) {
|
||||||
if (octstr_print(f, s) < 0) {
|
*error = octstr_format("fopen failed for %s: %s",
|
||||||
*error = octstr_format("send email failed in octstr_print %d: %s",
|
fname, strerror(errno));
|
||||||
errno, strerror(errno));
|
ret = MMS_SEND_ERROR_TRANSIENT;
|
||||||
pclose(f);
|
|
||||||
ret = MMS_SEND_ERROR_TRANSIENT;
|
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ret = pclose(f)) != 0) {
|
if (octstr_print(f, s) < 0) {
|
||||||
*error = octstr_format("Send email command returned non-zero %d: errno=%s",
|
*error = octstr_format("send email failed in write temp file %d: %s",
|
||||||
ret, strerror(errno));
|
errno, strerror(errno));
|
||||||
|
fclose(f);
|
||||||
ret = MMS_SEND_ERROR_TRANSIENT;
|
ret = MMS_SEND_ERROR_TRANSIENT;
|
||||||
|
goto done;
|
||||||
|
} else
|
||||||
|
fclose(f);
|
||||||
|
|
||||||
|
octstr_format_append(cmd, " < '%s'", fname);
|
||||||
|
|
||||||
|
debug("mms.sendtoemail", 0, "preparing to execute %s to send to email: ", octstr_get_cstr(cmd));
|
||||||
|
|
||||||
|
if (system(octstr_get_cstr(cmd)) != 0) {
|
||||||
|
*error = octstr_format("system(%S) failed: %d: %s",
|
||||||
|
cmd, errno, strerror(errno));
|
||||||
|
ret = MMS_SEND_ERROR_TRANSIENT;
|
||||||
|
goto done;
|
||||||
} else
|
} else
|
||||||
ret = MMS_SEND_QUEUED;
|
ret = MMS_SEND_QUEUED;
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
if (fname[0])
|
||||||
|
unlink(fname);
|
||||||
http_destroy_headers(headers);
|
http_destroy_headers(headers);
|
||||||
octstr_destroy(cmd);
|
octstr_destroy(cmd);
|
||||||
octstr_destroy(s);
|
octstr_destroy(s);
|
||||||
|
@ -715,7 +730,6 @@ int mms_sendtoemail(Octstr *from, Octstr *to,
|
||||||
char *transid,
|
char *transid,
|
||||||
List *extra_headers)
|
List *extra_headers)
|
||||||
{
|
{
|
||||||
|
|
||||||
MIMEEntity *m = NULL;
|
MIMEEntity *m = NULL;
|
||||||
List *headers = NULL;
|
List *headers = NULL;
|
||||||
List *newhdrs = http_create_empty_headers();
|
List *newhdrs = http_create_empty_headers();
|
||||||
|
|
|
@ -467,7 +467,7 @@ static int queue_dlr(MmscGrp *mmc, Octstr *from, Octstr *to, Octstr *msgid, Octs
|
||||||
|
|
||||||
rr_uri = mmsbox_get_report_info(m, mmc, mmc_id, "delivery-report", status, rqh, NULL, 0, msgid);
|
rr_uri = mmsbox_get_report_info(m, mmc, mmc_id, "delivery-report", status, rqh, NULL, 0, msgid);
|
||||||
|
|
||||||
mmsbox_event_cb(mmc->id, MM7_TAG_DeliveryReportReq, 0,octstr_imm("5.3.0"), 200,
|
mmsbox_event_cb(mmc ? mmc->id : NULL, MM7_TAG_DeliveryReportReq, 0,octstr_imm("5.3.0"), 200,
|
||||||
0, 0, from,
|
0, 0, from,
|
||||||
lto && gwlist_len(lto) > 0 ? gwlist_get(lto,0) : NULL,
|
lto && gwlist_len(lto) > 0 ? gwlist_get(lto,0) : NULL,
|
||||||
msgid, NULL, NULL, status);
|
msgid, NULL, NULL, status);
|
||||||
|
@ -539,7 +539,7 @@ static int mm7eaif_receive(MmsBoxHTTPClientInfo *h)
|
||||||
|
|
||||||
/* XXXX handle delivery reports differently. */
|
/* XXXX handle delivery reports differently. */
|
||||||
mtype = mms_messagetype(m);
|
mtype = mms_messagetype(m);
|
||||||
mm7type = mm7_msgtype_to_soaptype(mtype, 1);
|
mm7type = mm7_msgtype_to_soaptype(mtype, 0);
|
||||||
mh = mms_message_headers(m);
|
mh = mms_message_headers(m);
|
||||||
/* Now get sender and receiver data.
|
/* Now get sender and receiver data.
|
||||||
* for now we ignore adaptation flags.
|
* for now we ignore adaptation flags.
|
||||||
|
@ -803,7 +803,7 @@ static int mm7http_receive(MmsBoxHTTPClientInfo *h)
|
||||||
to = octstr_split_words(hto);
|
to = octstr_split_words(hto);
|
||||||
|
|
||||||
mtype = mms_messagetype(m);
|
mtype = mms_messagetype(m);
|
||||||
mm7type = mm7_msgtype_to_soaptype(mtype, 1);
|
mm7type = mm7_msgtype_to_soaptype(mtype, 0);
|
||||||
mh = mms_message_headers(m);
|
mh = mms_message_headers(m);
|
||||||
|
|
||||||
/* find interesting headers. */
|
/* find interesting headers. */
|
||||||
|
@ -1631,12 +1631,13 @@ static int sendMsg(MmsEnvelope *e)
|
||||||
"",
|
"",
|
||||||
"", 0,
|
"", 0,
|
||||||
e->xqfname,
|
e->xqfname,
|
||||||
e->hdrs);
|
e->hdrs);
|
||||||
if (res == MMS_SEND_OK || res == MMS_SEND_QUEUED)
|
if (res == MMS_SEND_OK || res == MMS_SEND_QUEUED) {
|
||||||
|
new_msgid = e->msgId ? octstr_duplicate(e->msgId) : octstr_create("00001"); /* Fake it */
|
||||||
mmsbox_event_cb(NULL, MM7_TAG_SubmitReq, 1, octstr_imm("1.0"), 200,
|
mmsbox_event_cb(NULL, MM7_TAG_SubmitReq, 1, octstr_imm("1.0"), 200,
|
||||||
mms_msgsize(msg), e->attempts, pfrom,
|
mms_msgsize(msg), e->attempts, pfrom,
|
||||||
to->rcpt,NULL, NULL, e->hdrs, NULL);
|
to->rcpt,NULL, NULL, e->hdrs, NULL);
|
||||||
|
}
|
||||||
octstr_destroy(pfrom);
|
octstr_destroy(pfrom);
|
||||||
octstr_destroy(xto);
|
octstr_destroy(xto);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1657,14 +1658,7 @@ static int sendMsg(MmsEnvelope *e)
|
||||||
octstr_destroy(x);
|
octstr_destroy(x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mmc) {
|
|
||||||
if (res == MMS_SEND_OK)
|
|
||||||
mmc->mt_pdus++;
|
|
||||||
else
|
|
||||||
mmc->mt_errors++;
|
|
||||||
mmc->last_pdu = time(NULL);
|
|
||||||
return_mmsc_conn(mmc); /* important. */
|
|
||||||
}
|
|
||||||
done:
|
done:
|
||||||
if (res == MMS_SEND_OK || res == MMS_SEND_QUEUED) {
|
if (res == MMS_SEND_OK || res == MMS_SEND_QUEUED) {
|
||||||
to->process = 0;
|
to->process = 0;
|
||||||
|
@ -1680,6 +1674,16 @@ static int sendMsg(MmsEnvelope *e)
|
||||||
octstr_imm("Expired") : octstr_imm("Rejected"),
|
octstr_imm("Expired") : octstr_imm("Rejected"),
|
||||||
"MM7-Out", errl);
|
"MM7-Out", errl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mmc) {
|
||||||
|
if (res == MMS_SEND_OK || res == MMS_SEND_QUEUED)
|
||||||
|
mmc->mt_pdus++;
|
||||||
|
else
|
||||||
|
mmc->mt_errors++;
|
||||||
|
mmc->last_pdu = time(NULL);
|
||||||
|
return_mmsc_conn(mmc); /* important. */
|
||||||
|
}
|
||||||
|
|
||||||
if (res == MMS_SEND_ERROR_FATAL)
|
if (res == MMS_SEND_ERROR_FATAL)
|
||||||
to->process = 0; /* No more attempts. */
|
to->process = 0; /* No more attempts. */
|
||||||
|
|
||||||
|
@ -1949,6 +1953,7 @@ static Octstr *handle_msg(MIMEEntity *mm, Octstr *from, List *to, MmscGrp *mmc)
|
||||||
} else
|
} else
|
||||||
msg = NULL;
|
msg = NULL;
|
||||||
|
|
||||||
|
mm7type = mm7_msgtype_to_soaptype(mm1_type,0);
|
||||||
me = octstr_format("system-user@%S", myhostname);
|
me = octstr_format("system-user@%S", myhostname);
|
||||||
|
|
||||||
qdir = get_mmsbox_queue_dir(from, to, mmc, &mmc_id); /* get routing info. */
|
qdir = get_mmsbox_queue_dir(from, to, mmc, &mmc_id); /* get routing info. */
|
||||||
|
@ -2085,7 +2090,7 @@ static Octstr *handle_msg(MIMEEntity *mm, Octstr *from, List *to, MmscGrp *mmc)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
mm7type = mm7_msgtype_to_soaptype(mm1_type,1);
|
|
||||||
if (mm7type >= 0) /* Issue event call back */
|
if (mm7type >= 0) /* Issue event call back */
|
||||||
mmsbox_event_cb(mmc->id, mm7type, 1, octstr_imm("1.0"), 200,
|
mmsbox_event_cb(mmc->id, mm7type, 1, octstr_imm("1.0"), 200,
|
||||||
mms_msgsize(msg), 0, from,
|
mms_msgsize(msg), 0, from,
|
||||||
|
@ -2101,7 +2106,11 @@ static Octstr *handle_msg(MIMEEntity *mm, Octstr *from, List *to, MmscGrp *mmc)
|
||||||
mmsbox_event_cb(mmc->id, mm7type >= 0 ? mm7type + 1 : MM7_TAG_VASPErrorRsp,
|
mmsbox_event_cb(mmc->id, mm7type >= 0 ? mm7type + 1 : MM7_TAG_VASPErrorRsp,
|
||||||
1, octstr_imm("1.0"), 200,
|
1, octstr_imm("1.0"), 200,
|
||||||
size, 0, me, orig_sys, res, NULL, NULL, NULL);
|
size, 0, me, orig_sys, res, NULL, NULL, NULL);
|
||||||
}
|
} else if (mtype == MM4_FORWARD_REQ) /* Or straight up SMTP */
|
||||||
|
mmsbox_event_cb(mmc->id, mm7type >= 0 ? mm7type + 1 : MM7_TAG_VASPErrorRsp,
|
||||||
|
1, octstr_imm("1.0"), 200,
|
||||||
|
0, 0, me, orig_sys, res, NULL, NULL, NULL);
|
||||||
|
|
||||||
octstr_destroy(mm4_type);
|
octstr_destroy(mm4_type);
|
||||||
octstr_destroy(transid);
|
octstr_destroy(transid);
|
||||||
octstr_destroy(orig_sys);
|
octstr_destroy(orig_sys);
|
||||||
|
|
|
@ -47,7 +47,7 @@ static int dlr_entry_fname(char *msgid, char *rtype, Octstr *mmc_gid, Octstr **e
|
||||||
d2[2] = '\0';
|
d2[2] = '\0';
|
||||||
|
|
||||||
/* Try and create the next level dir (first level was created by root_init) */
|
/* Try and create the next level dir (first level was created by root_init) */
|
||||||
sprintf(fbuf, "%s/%s/%s", octstr_get_cstr(dlr_dir), d1, d2);
|
sprintf(fbuf, "%.128s/%s/%s", octstr_get_cstr(dlr_dir), d1, d2);
|
||||||
if (mkdir(fbuf,
|
if (mkdir(fbuf,
|
||||||
S_IRWXU|S_IRWXG) < 0 &&
|
S_IRWXU|S_IRWXG) < 0 &&
|
||||||
errno != EEXIST) {
|
errno != EEXIST) {
|
||||||
|
|
|
@ -135,8 +135,7 @@ static void fill_cdr_struct(MmsBoxCdrStruct *cdr,
|
||||||
|
|
||||||
cdr->sdate = sdate;
|
cdr->sdate = sdate;
|
||||||
|
|
||||||
#define COPY_CDR_FIELD(fld) if (fld) \
|
#define COPY_CDR_FIELD(fld) if (fld) strncpy(cdr->fld, fld, sizeof cdr->fld)
|
||||||
strncpy(cdr->fld, fld, sizeof cdr->fld)
|
|
||||||
|
|
||||||
COPY_CDR_FIELD(from);
|
COPY_CDR_FIELD(from);
|
||||||
COPY_CDR_FIELD(to);
|
COPY_CDR_FIELD(to);
|
||||||
|
@ -164,7 +163,7 @@ static int cdr_module_logcdr(time_t sdate, char *from, char *to, char *msgid,
|
||||||
char *status,
|
char *status,
|
||||||
int dlr, int rr)
|
int dlr, int rr)
|
||||||
{
|
{
|
||||||
MmsBoxCdrStruct *xcdr = gw_malloc(sizeof *xcdr);
|
MmsBoxCdrStruct *xcdr = gw_malloc(sizeof xcdr[0]);
|
||||||
|
|
||||||
gw_assert(req_list);
|
gw_assert(req_list);
|
||||||
|
|
||||||
|
|
|
@ -549,10 +549,10 @@ static void mmsbox_stop_mmsc_conn_real(MmscGrp *mmc)
|
||||||
else if (mmc->incoming.port > 0) {
|
else if (mmc->incoming.port > 0) {
|
||||||
http_close_port(mmc->incoming.port);
|
http_close_port(mmc->incoming.port);
|
||||||
hmon->unregister_port(mmc->incoming.port);
|
hmon->unregister_port(mmc->incoming.port);
|
||||||
MMSC_ISSUE_ALARM(mmc, MMSBOX_ALARM_HTTP_DOWN, 1);
|
|
||||||
if (mmc->threadid >= 0)
|
if (mmc->threadid >= 0)
|
||||||
gwthread_join(mmc->threadid);
|
gwthread_join(mmc->threadid);
|
||||||
mmc->threadid = -1;
|
mmc->threadid = -1;
|
||||||
|
MMSC_ISSUE_ALARM(mmc, MMSBOX_ALARM_HTTP_DOWN, 1);
|
||||||
}
|
}
|
||||||
mms_info(0, "mmsbox", NULL,"Shutdown for mmsc [%s] complete", octstr_get_cstr(mmc->id));
|
mms_info(0, "mmsbox", NULL,"Shutdown for mmsc [%s] complete", octstr_get_cstr(mmc->id));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue