|
|
|
@ -359,7 +359,7 @@ static void handle_mm1(MM1Settings *mm1)
|
|
|
|
|
{
|
|
|
|
|
/* stop smsc, start GPRS, transact, stop GPRS, start SMSC. And so on. */
|
|
|
|
|
MM1Request *r;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mms_info(0, "mmsbox-mm1", NULL, "handle_mm1 started");
|
|
|
|
|
mm1->sender_alive++;
|
|
|
|
|
while ((r = gwlist_consume(mm1->requests)) != NULL) {
|
|
|
|
@ -512,10 +512,28 @@ static void handle_mm1(MM1Settings *mm1)
|
|
|
|
|
octstr_destroy(body);
|
|
|
|
|
octstr_destroy(ms);
|
|
|
|
|
mms_destroy(m);
|
|
|
|
|
} while (gwlist_len(mm1->requests) > 0 &&
|
|
|
|
|
r = NULL;
|
|
|
|
|
pid_t wp;
|
|
|
|
|
int st;
|
|
|
|
|
wp = waitpid(pid, &st, WNOHANG);
|
|
|
|
|
if(wp == pid && WIFEXITED(st)) {
|
|
|
|
|
mms_info(0, "mmsbox-mm1", NULL, "GPRS pid (%d) appears to be dead - quitting loop", pid);
|
|
|
|
|
goto after_gprs_dead;
|
|
|
|
|
}
|
|
|
|
|
} while (gwlist_len(mm1->requests) > 0 &&
|
|
|
|
|
(r = gwlist_consume(mm1->requests)) != NULL);
|
|
|
|
|
|
|
|
|
|
kill_gprs:
|
|
|
|
|
if(r != NULL) {
|
|
|
|
|
if(r->waiter_exists) {
|
|
|
|
|
pthread_mutex_unlock(&r->mutex);
|
|
|
|
|
pthread_cond_signal(&r->cond);
|
|
|
|
|
} else{
|
|
|
|
|
gw_free(r);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (pid > 0) { /* stop GPRS, restart SMSC connection. */
|
|
|
|
|
int xkill, status;
|
|
|
|
|
pid_t wpid;
|
|
|
|
@ -532,7 +550,7 @@ static void handle_mm1(MM1Settings *mm1)
|
|
|
|
|
} while (1);
|
|
|
|
|
gwthread_sleep(2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
after_gprs_dead:
|
|
|
|
|
if (mm1->smsc_on) {
|
|
|
|
|
system(octstr_get_cstr(mm1->smsc_on));
|
|
|
|
|
gwthread_sleep(5);
|
|
|
|
@ -610,10 +628,13 @@ static Octstr *fetch_content(Octstr *url, Octstr *proxy, Octstr *body, int *hsta
|
|
|
|
|
curl_easy_setopt(cl, CURLOPT_WRITEFUNCTION, write_octstr_data);
|
|
|
|
|
curl_easy_setopt(cl, CURLOPT_WRITEDATA, s);
|
|
|
|
|
curl_easy_setopt(cl, CURLOPT_NOSIGNAL, 1L);
|
|
|
|
|
curl_easy_setopt(cl, CURLOPT_TIMEOUT, 120L);
|
|
|
|
|
curl_easy_setopt(cl, CURLOPT_FORBID_REUSE, 1L);
|
|
|
|
|
curl_easy_setopt(cl, CURLOPT_CONNECTTIMEOUT, 40L);
|
|
|
|
|
|
|
|
|
|
h = curl_slist_append(h, "Accept: */*");
|
|
|
|
|
if (body) { /* POST. */
|
|
|
|
|
h = curl_slist_append(h, "Content-Type: application/vnd.wap.mms-message");
|
|
|
|
|
h = curl_slist_append(h, "Content-Type: application/vnd.wap.mms-message");
|
|
|
|
|
curl_easy_setopt(cl, CURLOPT_POSTFIELDS, octstr_get_cstr(body));
|
|
|
|
|
curl_easy_setopt(cl, CURLOPT_POSTFIELDSIZE, octstr_len(body));
|
|
|
|
|
}
|
|
|
|
@ -635,7 +656,7 @@ static Octstr *fetch_content(Octstr *url, Octstr *proxy, Octstr *body, int *hsta
|
|
|
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
|
|
#define MAX_GPRS_WAIT 60
|
|
|
|
|
#define MAX_GPRS_WAIT 80
|
|
|
|
|
#define GPRS_POLL 5
|
|
|
|
|
static long start_gprs(Octstr *cmd, Octstr *pid_cmd)
|
|
|
|
|
{
|
|
|
|
@ -661,6 +682,14 @@ static long start_gprs(Octstr *cmd, Octstr *pid_cmd)
|
|
|
|
|
WIFEXITED(status))
|
|
|
|
|
return -1;
|
|
|
|
|
} while (GPRS_POLL*ct++ < MAX_GPRS_WAIT);
|
|
|
|
|
/* Timed out, but still need to wait for child pid, as
|
|
|
|
|
start-gprs script is still running and we don't need a
|
|
|
|
|
zombie */
|
|
|
|
|
pid_t rpid;
|
|
|
|
|
int st;
|
|
|
|
|
|
|
|
|
|
rpid = waitpid(pid, &st, 0);
|
|
|
|
|
mms_info(0, "mmsbox-mm1", NULL, "pid %d terminated", pid);
|
|
|
|
|
return -1;
|
|
|
|
|
} else if (pid == 0) { /* child. */
|
|
|
|
|
List *l = octstr_split_words(cmd);
|
|
|
|
|