mirror of
https://github.com/yrutschle/sslh.git
synced 2025-04-13 07:37:15 +03:00
alloc_cnx returns cnx pointer instead of simple error code
This commit is contained in:
parent
a487ad4cbe
commit
41a914b350
@ -61,11 +61,11 @@ int collection_add_fd(cnx_collection* collection, struct connection* cnx, int fd
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Allocates a connection and inits it with specified file descriptor */
|
/* Allocates a connection and inits it with specified file descriptor */
|
||||||
int collection_alloc_cnx_from_fd(struct cnx_collection* collection, int fd)
|
struct connection* collection_alloc_cnx_from_fd(struct cnx_collection* collection, int fd)
|
||||||
{
|
{
|
||||||
struct connection* cnx = malloc(sizeof(*cnx));
|
struct connection* cnx = malloc(sizeof(*cnx));
|
||||||
|
|
||||||
if (!cnx) return -1;
|
if (!cnx) return NULL;
|
||||||
|
|
||||||
init_cnx(cnx);
|
init_cnx(cnx);
|
||||||
cnx->q[0].fd = fd;
|
cnx->q[0].fd = fd;
|
||||||
@ -74,7 +74,7 @@ int collection_alloc_cnx_from_fd(struct cnx_collection* collection, int fd)
|
|||||||
|
|
||||||
gap_set(collection->fd2cnx, fd, cnx);
|
gap_set(collection->fd2cnx, fd, cnx);
|
||||||
|
|
||||||
return 0;
|
return cnx;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Remove a connection from the collection */
|
/* Remove a connection from the collection */
|
||||||
|
@ -7,7 +7,7 @@ typedef struct cnx_collection cnx_collection;
|
|||||||
cnx_collection* collection_init(void);
|
cnx_collection* collection_init(void);
|
||||||
void collection_destroy(cnx_collection* collection);
|
void collection_destroy(cnx_collection* collection);
|
||||||
|
|
||||||
int collection_alloc_cnx_from_fd(cnx_collection* collection, int fd);
|
struct connection* collection_alloc_cnx_from_fd(cnx_collection* collection, int fd);
|
||||||
int collection_add_fd(cnx_collection* collection, struct connection* cnx, int fd);
|
int collection_add_fd(cnx_collection* collection, struct connection* cnx, int fd);
|
||||||
|
|
||||||
/* Remove a connection from the collection */
|
/* Remove a connection from the collection */
|
||||||
|
@ -113,8 +113,8 @@ static int accept_new_connection(int listen_socket, struct cnx_collection *colle
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = collection_alloc_cnx_from_fd(collection, in_socket);
|
struct connection* cnx = collection_alloc_cnx_from_fd(collection, in_socket);
|
||||||
if (res == -1) {
|
if (!cnx) {
|
||||||
close(in_socket);
|
close(in_socket);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user