mirror of
https://github.com/yrutschle/sslh.git
synced 2025-04-12 23:27: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 */
|
||||
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));
|
||||
|
||||
if (!cnx) return -1;
|
||||
if (!cnx) return NULL;
|
||||
|
||||
init_cnx(cnx);
|
||||
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);
|
||||
|
||||
return 0;
|
||||
return cnx;
|
||||
}
|
||||
|
||||
/* Remove a connection from the collection */
|
||||
|
@ -7,7 +7,7 @@ typedef struct cnx_collection cnx_collection;
|
||||
cnx_collection* collection_init(void);
|
||||
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);
|
||||
|
||||
/* Remove a connection from the collection */
|
||||
|
@ -113,8 +113,8 @@ static int accept_new_connection(int listen_socket, struct cnx_collection *colle
|
||||
return -1;
|
||||
}
|
||||
|
||||
res = collection_alloc_cnx_from_fd(collection, in_socket);
|
||||
if (res == -1) {
|
||||
struct connection* cnx = collection_alloc_cnx_from_fd(collection, in_socket);
|
||||
if (!cnx) {
|
||||
close(in_socket);
|
||||
return -1;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user