static void run_sqlbox(void *arg) { int fd; Boxc *newconn; long sender; fd = (int)arg; newconn = accept_boxc(fd, sqlbox_port_ssl); if (newconn == NULL) { panic(0, "Socket accept failed"); return; } newconn->bearerbox_connection = connect_to_bearerbox_real(bearerbox_host, bearerbox_port, bearerbox_port_ssl, NULL /* bb_our_host */); /* XXX add our_host if required */ sender = gwthread_create(bearerbox_to_smsbox, newconn); if (sender == -1) { error(0, "Failed to start a new thread, disconnecting client <%s>", octstr_get_cstr(newconn->client_ip)); //goto cleanup; } smsbox_to_bearerbox(newconn); gwthread_join(sender); boxc_destroy(newconn); }
static void sql_to_bearerbox(void *arg) { Boxc *boxc; boxc = gw_malloc(sizeof(Boxc)); boxc->bearerbox_connection = connect_to_bearerbox_real(bearerbox_host, bearerbox_port, bearerbox_port_ssl, NULL /* bb_our_host */); boxc->smsbox_connection = NULL; boxc->client_ip = NULL; boxc->alive = 1; boxc->connect_time = time(NULL); boxc->boxc_id = octstr_duplicate(sqlbox_id); if (boxc->bearerbox_connection == NULL) { boxc_destroy(boxc); return; } gwthread_create(bearerbox_to_sql, boxc); identify_to_bearerbox(boxc); if (gw_sql_fetch_msg_list == NULL || gw_sql_save_list == NULL || limit_per_cycle <= 1) { sql_single(boxc); } else { sql_list(boxc); } boxc_destroy(boxc); }
void connect_to_bearerbox(Octstr *host, int port, int ssl, Octstr *our_host) { bb_conn = connect_to_bearerbox_real(host, port, ssl, our_host); if (bb_conn == NULL) panic(0, "Couldn't connect to the bearerbox."); }