Commit 53b784b1 authored by Ake Hedman's avatar Ake Hedman

connection_data -> user_data

parent 8e91e3a3
...@@ -209,7 +209,7 @@ struct ns_connection { ...@@ -209,7 +209,7 @@ struct ns_connection {
struct iobuf send_iobuf; struct iobuf send_iobuf;
SSL *ssl; SSL *ssl;
SSL_CTX *ssl_ctx; SSL_CTX *ssl_ctx;
void *connection_data; void *user_data;
time_t last_io_time; time_t last_io_time;
unsigned int flags; unsigned int flags;
...@@ -462,7 +462,7 @@ static void hexdump(struct ns_connection *nc, const char *path, ...@@ -462,7 +462,7 @@ static void hexdump(struct ns_connection *nc, const char *path,
ns_sock_to_str(nc->sock, src, sizeof(src), 3); ns_sock_to_str(nc->sock, src, sizeof(src), 3);
ns_sock_to_str(nc->sock, dst, sizeof(dst), 7); ns_sock_to_str(nc->sock, dst, sizeof(dst), 7);
fprintf(fp, "%lu %p %s %s %s %d\n", (unsigned long) time(NULL), fprintf(fp, "%lu %p %s %s %s %d\n", (unsigned long) time(NULL),
nc->connection_data, src, nc->user_data, src,
ev == NS_RECV ? "<-" : ev == NS_SEND ? "->" : ev == NS_RECV ? "<-" : ev == NS_SEND ? "->" :
ev == NS_ACCEPT ? "<A" : ev == NS_CONNECT ? "C>" : "XX", ev == NS_ACCEPT ? "<A" : ev == NS_CONNECT ? "C>" : "XX",
dst, num_bytes); dst, num_bytes);
...@@ -720,7 +720,7 @@ struct ns_connection *ns_bind(struct ns_mgr *srv, const char *str, void *data) { ...@@ -720,7 +720,7 @@ struct ns_connection *ns_bind(struct ns_mgr *srv, const char *str, void *data) {
} else { } else {
nc->sa = sa; nc->sa = sa;
nc->flags |= NSF_LISTENING; nc->flags |= NSF_LISTENING;
nc->connection_data = data; nc->user_data = data;
if (proto == SOCK_DGRAM) { if (proto == SOCK_DGRAM) {
nc->flags |= NSF_UDP; nc->flags |= NSF_UDP;
...@@ -1129,7 +1129,7 @@ struct ns_connection *ns_add_sock(struct ns_mgr *s, sock_t sock, void *p) { ...@@ -1129,7 +1129,7 @@ struct ns_connection *ns_add_sock(struct ns_mgr *s, sock_t sock, void *p) {
ns_set_non_blocking_mode(sock); ns_set_non_blocking_mode(sock);
ns_set_close_on_exec(sock); ns_set_close_on_exec(sock);
conn->sock = sock; conn->sock = sock;
conn->connection_data = p; conn->user_data = p;
conn->mgr = s; conn->mgr = s;
conn->last_io_time = time(NULL); conn->last_io_time = time(NULL);
ns_add_conn(s, conn); ns_add_conn(s, conn);
...@@ -2209,7 +2209,7 @@ static void open_cgi_endpoint(struct connection *conn, const char *prog) { ...@@ -2209,7 +2209,7 @@ static void open_cgi_endpoint(struct connection *conn, const char *prog) {
} }
static void on_cgi_data(struct ns_connection *nc) { static void on_cgi_data(struct ns_connection *nc) {
struct connection *conn = (struct connection *) nc->connection_data; struct connection *conn = (struct connection *) nc->user_data;
const char *status = "500"; const char *status = "500";
struct mg_connection c; struct mg_connection c;
...@@ -4629,7 +4629,7 @@ struct mg_connection *mg_connect(struct mg_server *server, const char *addr) { ...@@ -4629,7 +4629,7 @@ struct mg_connection *mg_connect(struct mg_server *server, const char *addr) {
// Interlink two structs // Interlink two structs
conn->ns_conn = nsconn; conn->ns_conn = nsconn;
nsconn->connection_data = conn; nsconn->user_data = conn;
conn->server = server; conn->server = server;
conn->endpoint_type = EP_CLIENT; conn->endpoint_type = EP_CLIENT;
...@@ -4699,7 +4699,7 @@ static void close_local_endpoint(struct connection *conn) { ...@@ -4699,7 +4699,7 @@ static void close_local_endpoint(struct connection *conn) {
if (conn->endpoint.nc != NULL) { if (conn->endpoint.nc != NULL) {
DBG(("%p %p %p :-)", conn, conn->ns_conn, conn->endpoint.nc)); DBG(("%p %p %p :-)", conn, conn->ns_conn, conn->endpoint.nc));
conn->endpoint.nc->flags |= NSF_CLOSE_IMMEDIATELY; conn->endpoint.nc->flags |= NSF_CLOSE_IMMEDIATELY;
conn->endpoint.nc->connection_data = NULL; conn->endpoint.nc->user_data = NULL;
} }
break; break;
default: break; default: break;
...@@ -4784,8 +4784,8 @@ struct mg_connection *mg_next(struct mg_server *s, struct mg_connection *c) { ...@@ -4784,8 +4784,8 @@ struct mg_connection *mg_next(struct mg_server *s, struct mg_connection *c) {
struct connection *conn = MG_CONN_2_CONN(c); struct connection *conn = MG_CONN_2_CONN(c);
struct ns_connection *nc = ns_next(&s->ns_mgr, struct ns_connection *nc = ns_next(&s->ns_mgr,
c == NULL ? NULL : conn->ns_conn); c == NULL ? NULL : conn->ns_conn);
if (nc != NULL && nc->connection_data != NULL) { if (nc != NULL && nc->user_data != NULL) {
return & ((struct connection *) nc->connection_data)->mg_conn; return & ((struct connection *) nc->user_data)->mg_conn;
} else { } else {
return NULL; return NULL;
} }
...@@ -4976,7 +4976,7 @@ const char *mg_set_option(struct mg_server *server, const char *name, ...@@ -4976,7 +4976,7 @@ const char *mg_set_option(struct mg_server *server, const char *name,
} }
static void set_ips(struct ns_connection *nc, int is_rem) { static void set_ips(struct ns_connection *nc, int is_rem) {
struct connection *conn = (struct connection *) nc->connection_data; struct connection *conn = (struct connection *) nc->user_data;
struct mg_connection *c = &conn->mg_conn; struct mg_connection *c = &conn->mg_conn;
char buf[100]; char buf[100];
...@@ -4997,7 +4997,7 @@ static void on_accept(struct ns_connection *nc, union socket_address *sa) { ...@@ -4997,7 +4997,7 @@ static void on_accept(struct ns_connection *nc, union socket_address *sa) {
nc->flags |= NSF_CLOSE_IMMEDIATELY; nc->flags |= NSF_CLOSE_IMMEDIATELY;
} else { } else {
// Circularly link two connection structures // Circularly link two connection structures
nc->connection_data = conn; nc->user_data = conn;
conn->ns_conn = nc; conn->ns_conn = nc;
// Initialize the rest of connection attributes // Initialize the rest of connection attributes
...@@ -5021,13 +5021,13 @@ static void process_udp(struct ns_connection *nc) { ...@@ -5021,13 +5021,13 @@ static void process_udp(struct ns_connection *nc) {
} }
static void mg_ev_handler(struct ns_connection *nc, enum ns_event ev, void *p) { static void mg_ev_handler(struct ns_connection *nc, enum ns_event ev, void *p) {
struct connection *conn = (struct connection *) nc->connection_data; struct connection *conn = (struct connection *) nc->user_data;
// Send NS event to the handler. Note that call_user won't send an event // Send NS event to the handler. Note that call_user won't send an event
// if conn == NULL. Therefore, repeat this for NS_ACCEPT event as well. // if conn == NULL. Therefore, repeat this for NS_ACCEPT event as well.
#ifdef MONGOOSE_SEND_NS_EVENTS #ifdef MONGOOSE_SEND_NS_EVENTS
{ {
struct connection *conn = (struct connection *) nc->connection_data; struct connection *conn = (struct connection *) nc->user_data;
void *param[2] = { nc, p }; void *param[2] = { nc, p };
if (conn != NULL) conn->mg_conn.callback_param = param; if (conn != NULL) conn->mg_conn.callback_param = param;
call_user(conn, (enum mg_event) ev); call_user(conn, (enum mg_event) ev);
...@@ -5039,7 +5039,7 @@ static void mg_ev_handler(struct ns_connection *nc, enum ns_event ev, void *p) { ...@@ -5039,7 +5039,7 @@ static void mg_ev_handler(struct ns_connection *nc, enum ns_event ev, void *p) {
on_accept(nc, (union socket_address *) p); on_accept(nc, (union socket_address *) p);
#ifdef MONGOOSE_SEND_NS_EVENTS #ifdef MONGOOSE_SEND_NS_EVENTS
{ {
struct connection *conn = (struct connection *) nc->connection_data; struct connection *conn = (struct connection *) nc->user_data;
void *param[2] = { nc, p }; void *param[2] = { nc, p };
if (conn != NULL) conn->mg_conn.callback_param = param; if (conn != NULL) conn->mg_conn.callback_param = param;
call_user(conn, (enum mg_event) ev); call_user(conn, (enum mg_event) ev);
...@@ -5048,7 +5048,7 @@ static void mg_ev_handler(struct ns_connection *nc, enum ns_event ev, void *p) { ...@@ -5048,7 +5048,7 @@ static void mg_ev_handler(struct ns_connection *nc, enum ns_event ev, void *p) {
break; break;
case NS_CONNECT: case NS_CONNECT:
if (nc->connection_data != NULL) { if (nc->user_data != NULL) {
set_ips(nc, 1); set_ips(nc, 1);
set_ips(nc, 0); set_ips(nc, 0);
} }
...@@ -5086,7 +5086,7 @@ static void mg_ev_handler(struct ns_connection *nc, enum ns_event ev, void *p) { ...@@ -5086,7 +5086,7 @@ static void mg_ev_handler(struct ns_connection *nc, enum ns_event ev, void *p) {
break; break;
case NS_CLOSE: case NS_CLOSE:
nc->connection_data = NULL; nc->user_data = NULL;
if (nc->flags & (MG_CGI_CONN | MG_PROXY_CONN)) { if (nc->flags & (MG_CGI_CONN | MG_PROXY_CONN)) {
DBG(("%p %p closing cgi/proxy conn", conn, nc)); DBG(("%p %p closing cgi/proxy conn", conn, nc));
if (conn && conn->ns_conn) { if (conn && conn->ns_conn) {
...@@ -5146,7 +5146,7 @@ static void mg_ev_handler(struct ns_connection *nc, enum ns_event ev, void *p) { ...@@ -5146,7 +5146,7 @@ static void mg_ev_handler(struct ns_connection *nc, enum ns_event ev, void *p) {
static void iter2(struct ns_connection *nc, enum ns_event ev, void *param) { static void iter2(struct ns_connection *nc, enum ns_event ev, void *param) {
mg_handler_t func = NULL; mg_handler_t func = NULL;
struct connection *conn = (struct connection *) nc->connection_data; struct connection *conn = (struct connection *) nc->user_data;
const char *msg = (const char *) param; const char *msg = (const char *) param;
int n; int n;
(void) ev; (void) ev;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment