diff options
author | cbdev <cb@cbcdn.com> | 2020-05-30 12:23:32 +0200 |
---|---|---|
committer | cbdev <cb@cbcdn.com> | 2020-05-30 12:23:32 +0200 |
commit | 51b281340ba319eaa8399d507b00eaefa6c6a469 (patch) | |
tree | 4523860d4356513a0d66fa14d8ca02d75d1322d2 /backends | |
parent | 9dc10f402022cd4812a3644761d8af91d0852a0e (diff) | |
download | midimonster-51b281340ba319eaa8399d507b00eaefa6c6a469.tar.gz midimonster-51b281340ba319eaa8399d507b00eaefa6c6a469.tar.bz2 midimonster-51b281340ba319eaa8399d507b00eaefa6c6a469.zip |
maweb: Try next host (if configured) on login failure
Diffstat (limited to 'backends')
-rw-r--r-- | backends/maweb.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/backends/maweb.c b/backends/maweb.c index 980a914..297fb5f 100644 --- a/backends/maweb.c +++ b/backends/maweb.c @@ -593,15 +593,24 @@ static int maweb_handle_message(instance* inst, char* payload, size_t payload_le if(json_obj_bool(payload, "result", 0)){ LOG("Login successful"); data->login = 1; - + //initially request playbacks if(!update_interval){ maweb_request_playbacks(inst); } } else{ - LOG("Login failed"); data->login = 0; + + if(data->hosts > 1){ + LOGPF("Console login failed on %s, will try again with the next host", inst->name); + //mark as closed to reconnect + data->state = ws_closed; + } + else{ + LOGPF("Console login failed on %s", inst->name); + } + return 0; } } if(!strncmp(field, "playbacks", 9)){ @@ -621,10 +630,13 @@ static int maweb_handle_message(instance* inst, char* payload, size_t payload_le if(json_obj(payload, "session") == JSON_NUMBER){ session = json_obj_int(payload, "session", data->session); if(session < 0){ - LOG("Login failed"); - data->session = -1; - data->login = 0; - return 0; + LOG("Invalid session ID received, closing connection"); + data->session = -1; + data->login = 0; + + //this should be enough to mark the socket for the next keepalive/establish run + data->state = ws_closed; + return 0; } if(data->session != session){ LOGPF("Session ID changed from %" PRId64 " to %" PRId64 "", data->session, session); |