diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2018-10-10 09:11:47 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2018-10-10 14:06:28 +0200 |
commit | 0f0e130051cd4aba49885681c60ff226927e143e (patch) | |
tree | 70d14841d9c7d06f5b2c760c21e4a47e3a6e9559 | |
parent | telnetd: Create server socket at start (diff) | |
download | rtems-0f0e130051cd4aba49885681c60ff226927e143e.tar.bz2 |
telnetd: Allocate the server context
Update #3543.
Diffstat (limited to '')
-rw-r--r-- | cpukit/telnetd/telnetd.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/cpukit/telnetd/telnetd.c b/cpukit/telnetd/telnetd.c index 0fd3b317a9..aadf33deb7 100644 --- a/cpukit/telnetd/telnetd.c +++ b/cpukit/telnetd/telnetd.c @@ -81,9 +81,6 @@ typedef union uni_sa { struct sockaddr sa; } uni_sa; -/***********************************************************/ -static telnetd_context telnetd_instance; - static telnetd_session *grab_a_Connection(telnetd_context *ctx) { telnetd_session *session; @@ -245,6 +242,8 @@ static void telnetd_destroy_context(telnetd_context *ctx) if (ctx->server_socket >= 0) { close(ctx->server_socket); } + + free(ctx); } static rtems_status_code telnetd_create_server_socket(telnetd_context *ctx) @@ -288,7 +287,7 @@ static rtems_status_code telnetd_create_server_socket(telnetd_context *ctx) rtems_status_code rtems_telnetd_start(const rtems_telnetd_config_table* config) { - telnetd_context *ctx = &telnetd_instance; + telnetd_context *ctx; rtems_id task_id; rtems_status_code sc; @@ -297,12 +296,14 @@ rtems_status_code rtems_telnetd_start(const rtems_telnetd_config_table* config) return RTEMS_INVALID_ADDRESS; } - if (ctx->config.command != NULL) { - syslog(LOG_DAEMON | LOG_ERR, "telnetd: already started"); - return RTEMS_RESOURCE_IN_USE; + ctx = calloc(1, sizeof(*ctx)); + if (ctx == NULL) { + syslog(LOG_DAEMON | LOG_ERR, "telnetd: cannot allocate server context"); + return RTEMS_UNSATISFIED; } ctx->config = *config; + ctx->server_socket = -1; /* Check priority */ #ifdef RTEMS_NETWORKING |