net: make mars_create_socket() options dynamic

This commit is contained in:
Thomas Schoebel-Theuer 2018-05-10 09:25:34 +02:00 committed by Thomas Schoebel-Theuer
parent 922a82d25e
commit 2dff1c0c14
5 changed files with 21 additions and 6 deletions

View File

@ -145,7 +145,10 @@ int _setup_channel(struct client_bundle *bundle, int ch_nr)
goto done;
}
status = mars_create_socket(&ch->socket, &sockaddr, false);
status = mars_create_socket(&ch->socket,
&sockaddr,
&default_tcp_params,
false);
if (unlikely(status < 0)) {
MARS_DBG("no socket, status = %d\n", status);
goto really_done;

View File

@ -184,7 +184,10 @@ void _set_socketopts(struct socket *sock, struct mars_tcp_params *params)
}
}
int mars_create_socket(struct mars_socket *msock, struct sockaddr_storage *addr, bool is_server)
int mars_create_socket(struct mars_socket *msock,
struct sockaddr_storage *addr,
struct mars_tcp_params *params,
bool is_server)
{
struct socket *sock;
struct sockaddr *sockaddr = (void*)addr;
@ -218,7 +221,7 @@ int mars_create_socket(struct mars_socket *msock, struct sockaddr_storage *addr,
msock->s_alive = true;
msock->s_connected = false;
_set_socketopts(sock, &default_tcp_params);
_set_socketopts(sock, params);
if (is_server) {
status = kernel_bind(sock, sockaddr, sizeof(*sockaddr));

View File

@ -120,7 +120,10 @@ extern char *(*mars_translate_hostname)(const char *name);
*/
extern int mars_create_sockaddr(struct sockaddr_storage *addr, const char *spec);
extern int mars_create_socket(struct mars_socket *msock, struct sockaddr_storage *addr, bool is_server);
extern int mars_create_socket(struct mars_socket *msock,
struct sockaddr_storage *addr,
struct mars_tcp_params *params,
bool is_server);
extern int mars_accept_socket(struct mars_socket *new_msock, struct mars_socket *old_msock);
extern bool mars_get_socket(struct mars_socket *msock);
extern void mars_put_socket(struct mars_socket *msock);

View File

@ -969,7 +969,10 @@ int __init init_mars_server(void)
return status;
}
status = mars_create_socket(&server_socket[i], &sockaddr, true);
status = mars_create_socket(&server_socket[i],
&sockaddr,
&default_tcp_params,
true);
if (unlikely(status < 0)) {
MARS_ERR("could not create server socket %d, status = %d\n", i, status);
exit_mars_server();

View File

@ -2269,7 +2269,10 @@ int peer_thread(void *data)
if (!peer_thead_should_run(peer))
break;
status = mars_create_socket(&peer->socket, &sockaddr, false);
status = mars_create_socket(&peer->socket,
&sockaddr,
&default_tcp_params,
false);
if (unlikely(status < 0)) {
MARS_INF("no connection to mars module on '%s' (%s) status = %d\n", peer->peer, real_peer, status);
make_msg(peer_pairs, "connection to '%s' (%s) could not be established: status = %d", peer->peer, real_peer, status);