minor fix on error handling

This commit is contained in:
lxsang 2020-08-09 13:04:20 +02:00
parent d2aa1f3557
commit bd2c19d09a
5 changed files with 17 additions and 2 deletions

Binary file not shown.

Binary file not shown.

View File

@ -357,6 +357,13 @@ int main(int argc, char** argv)
if(msg.data) if(msg.data)
free(msg.data); free(msg.data);
} }
else
{
M_ERROR(MODULE_NAME, "Channel is not created: %s. Tunnel service responds with msg of type %d", MODULE_NAME, msg.header.type);
if(msg.data)
free(msg.data);
running = 0;
}
// now read data // now read data
while(running) while(running)

Binary file not shown.

View File

@ -121,6 +121,14 @@ int main(int argc, char** argv)
if(msg.data) if(msg.data)
free(msg.data); free(msg.data);
} }
else
{
M_ERROR(MODULE_NAME, "Channel is not created: %s. Tunnel service responds with msg of type %d", argv[2], msg.header.type);
if(msg.data)
free(msg.data);
running = 0;
}
// now read data // now read data
while(running) while(running)
@ -187,7 +195,7 @@ int main(int argc, char** argv)
msg.header.type = CHANNEL_ERROR; msg.header.type = CHANNEL_ERROR;
msg.header.size = strlen(buff); msg.header.size = strlen(buff);
tmp = msg.data; tmp = msg.data;
msg.data = buff; msg.data = (uint8_t*)buff;
if(msg_write(fd, &msg) == -1) if(msg_write(fd, &msg) == -1)
{ {
M_ERROR(MODULE_NAME, "Unable to write message to hotline"); M_ERROR(MODULE_NAME, "Unable to write message to hotline");
@ -221,7 +229,7 @@ int main(int argc, char** argv)
{ {
msg.header.type = CHANNEL_DATA; msg.header.type = CHANNEL_DATA;
msg.header.size = status; msg.header.size = status;
msg.data = buff; msg.data = (uint8_t*)buff;
fargv[0] = (void*) &msg; fargv[0] = (void*) &msg;
fargv[1] = (void*) &fd; fargv[1] = (void*) &fd;
bst_for_each(clients, send_data, fargv, 2); bst_for_each(clients, send_data, fargv, 2);