long content_create(spdid_t spdid, long evt_id, struct cos_array *d) { struct connection *c = http_new_connection(0, evt_id); long c_id; // printc("HTTP open connection"); if (NULL == c) return -ENOMEM; c_id = cos_map_add(&conn_map, c); if (c_id < 0) { http_free_connection(c); return -ENOMEM; } c->conn_id = c_id; return c_id; }
// called when a client connects to our server static void ICACHE_FLASH_ATTR http_ws_connect_callback(void *arg) { struct espconn *conn=arg; http_connection *c = http_new_connection(1,conn); // get a connection from the pool, signal it's an incomming connection c->cgi.execute = http_ws_cgi_execute; // attach our cgi dispatcher //attach app callback to cgi function c->cgi.function=app_callback; c->handshake_ok=0; //let's disable NAGLE alg so TCP outputs faster ( in theory ) espconn_set_opt(conn, ESPCONN_NODELAY | ESPCONN_REUSEADDR ); //override timeout to 240s espconn_regist_time(conn,240,0); }
td_t tsplit(spdid_t spdid, td_t tid, char *param, int len, tor_flags_t tflags, long evtid) { td_t ret = -1; struct torrent *t; struct connection *c; if (tor_isnull(tid)) return -EINVAL; LOCK(); c = http_new_connection(0, evtid); if (!c) ERR_THROW(-ENOMEM, err); /* ignore the param for now */ t = tor_alloc(c, tflags); if (!t) ERR_THROW(-ENOMEM, free); c->conn_id = ret = t->td; err: UNLOCK(); return ret; free: http_free_connection(c); goto err; }