Commit 60a470cc authored by Ian Craggs's avatar Ian Craggs

Changed some trace info to PROTOCOL to help with debugging

parent 62db601e
...@@ -886,7 +886,7 @@ int MQTTClient_connectURIVersion(MQTTClient handle, MQTTClient_connectOptions* o ...@@ -886,7 +886,7 @@ int MQTTClient_connectURIVersion(MQTTClient handle, MQTTClient_connectOptions* o
else else
{ {
Connack* connack = (Connack*)pack; Connack* connack = (Connack*)pack;
Log(LOG_PROTOCOL, 1, NULL, m->c->net.socket, m->c->clientID, connack->rc); Log(TRACE_PROTOCOL, 1, NULL, m->c->net.socket, m->c->clientID, connack->rc);
if ((rc = connack->rc) == MQTTCLIENT_SUCCESS) if ((rc = connack->rc) == MQTTCLIENT_SUCCESS)
{ {
m->c->connected = 1; m->c->connected = 1;
...@@ -1632,7 +1632,7 @@ MQTTPacket* MQTTClient_waitfor(MQTTClient handle, int packet_type, int* rc, long ...@@ -1632,7 +1632,7 @@ MQTTPacket* MQTTClient_waitfor(MQTTClient handle, int packet_type, int* rc, long
else if (packet_type == UNSUBACK) else if (packet_type == UNSUBACK)
*rc = Thread_wait_sem(m->unsuback_sem, timeout); *rc = Thread_wait_sem(m->unsuback_sem, timeout);
if (*rc == 0 && packet_type != CONNECT && m->pack == NULL) if (*rc == 0 && packet_type != CONNECT && m->pack == NULL)
Log(TRACE_MIN, -1, "waitfor unexpectedly is NULL for client %s, packet_type %d, timeout %ld", m->c->clientID, packet_type, timeout); Log(LOG_ERROR, -1, "waitfor unexpectedly is NULL for client %s, packet_type %d, timeout %ld", m->c->clientID, packet_type, timeout);
pack = m->pack; pack = m->pack;
} }
else else
......
...@@ -522,7 +522,7 @@ void MQTTProtocol_keepalive(time_t now) ...@@ -522,7 +522,7 @@ void MQTTProtocol_keepalive(time_t now)
{ {
if (MQTTPacket_send_pingreq(&client->net, client->clientID) != TCPSOCKET_COMPLETE) if (MQTTPacket_send_pingreq(&client->net, client->clientID) != TCPSOCKET_COMPLETE)
{ {
Log(TRACE_MIN, -1, "Error sending PINGREQ for client %s on socket %d, disconnecting", client->clientID, client->net.socket); Log(TRACE_PROTOCOL, -1, "Error sending PINGREQ for client %s on socket %d, disconnecting", client->clientID, client->net.socket);
MQTTProtocol_closeSession(client, 1); MQTTProtocol_closeSession(client, 1);
} }
else else
...@@ -534,7 +534,7 @@ void MQTTProtocol_keepalive(time_t now) ...@@ -534,7 +534,7 @@ void MQTTProtocol_keepalive(time_t now)
} }
else else
{ {
Log(TRACE_MIN, -1, "PINGRESP not received in keepalive interval for client %s on socket %d, disconnecting", client->clientID, client->net.socket); Log(TRACE_PROTOCOL, -1, "PINGRESP not received in keepalive interval for client %s on socket %d, disconnecting", client->clientID, client->net.socket);
MQTTProtocol_closeSession(client, 1); MQTTProtocol_closeSession(client, 1);
} }
} }
...@@ -578,7 +578,7 @@ void MQTTProtocol_retries(time_t now, Clients* client) ...@@ -578,7 +578,7 @@ void MQTTProtocol_retries(time_t now, Clients* client)
if (rc == SOCKET_ERROR) if (rc == SOCKET_ERROR)
{ {
client->good = 0; client->good = 0;
Log(TRACE_MIN, 8, NULL, client->clientID, client->net.socket, Log(TRACE_PROTOCOL, 29, NULL, client->clientID, client->net.socket,
Socket_getpeer(client->net.socket)); Socket_getpeer(client->net.socket));
MQTTProtocol_closeSession(client, 1); MQTTProtocol_closeSession(client, 1);
client = NULL; client = NULL;
...@@ -596,7 +596,7 @@ void MQTTProtocol_retries(time_t now, Clients* client) ...@@ -596,7 +596,7 @@ void MQTTProtocol_retries(time_t now, Clients* client)
if (MQTTPacket_send_pubrel(m->msgid, 1, &client->net, client->clientID) != TCPSOCKET_COMPLETE) if (MQTTPacket_send_pubrel(m->msgid, 1, &client->net, client->clientID) != TCPSOCKET_COMPLETE)
{ {
client->good = 0; client->good = 0;
Log(TRACE_MIN, 8, NULL, client->clientID, client->net.socket, Log(TRACE_PROTOCOL, 29, NULL, client->clientID, client->net.socket,
Socket_getpeer(client->net.socket)); Socket_getpeer(client->net.socket));
MQTTProtocol_closeSession(client, 1); MQTTProtocol_closeSession(client, 1);
client = NULL; client = NULL;
......
...@@ -66,6 +66,7 @@ static char* protocol_message_list[] = ...@@ -66,6 +66,7 @@ static char* protocol_message_list[] =
"%d %s <- CONNECT", /* 26 */ "%d %s <- CONNECT", /* 26 */
"%d %s -> PUBLISH qos: 0 retained: %d (%d)", /* 27 */ "%d %s -> PUBLISH qos: 0 retained: %d (%d)", /* 27 */
"%d %s -> DISCONNECT (%d)", /* 28 */ "%d %s -> DISCONNECT (%d)", /* 28 */
"Socket error for client identifier %s, socket %d, peer address %s; ending connection", /* 29 */
}; };
static char* trace_message_list[] = static char* trace_message_list[] =
...@@ -78,7 +79,7 @@ static char* trace_message_list[] = ...@@ -78,7 +79,7 @@ static char* trace_message_list[] =
"Packet %s received from client %s for message identifier %d, but message is in wrong state", /* 5 */ "Packet %s received from client %s for message identifier %d, but message is in wrong state", /* 5 */
"%s received from client %s for message id %d - removing publication", /* 6 */ "%s received from client %s for message id %d - removing publication", /* 6 */
"Trying %s again for client %s, socket %d, message identifier %d", /* 7 */ "Trying %s again for client %s, socket %d, message identifier %d", /* 7 */
"Socket error for client identifier %s, socket %d, peer address %s; ending connection", /* 8 */ "", /* 8 */
"(%lu) %*s(%d)> %s:%d", /* 9 */ "(%lu) %*s(%d)> %s:%d", /* 9 */
"(%lu) %*s(%d)< %s:%d", /* 10 */ "(%lu) %*s(%d)< %s:%d", /* 10 */
"(%lu) %*s(%d)< %s:%d (%d)", /* 11 */ "(%lu) %*s(%d)< %s:%d (%d)", /* 11 */
......
...@@ -98,7 +98,7 @@ int Socket_error(char* aString, int sock) ...@@ -98,7 +98,7 @@ int Socket_error(char* aString, int sock)
if (errno != EINTR && errno != EAGAIN && errno != EINPROGRESS && errno != EWOULDBLOCK) if (errno != EINTR && errno != EAGAIN && errno != EINPROGRESS && errno != EWOULDBLOCK)
{ {
if (strcmp(aString, "shutdown") != 0 || (errno != ENOTCONN && errno != ECONNRESET)) if (strcmp(aString, "shutdown") != 0 || (errno != ENOTCONN && errno != ECONNRESET))
Log(TRACE_MIN, -1, "Socket error %s in %s for socket %d", strerror(errno), aString, sock); Log(LOG_ERROR, -1, "Socket error %s in %s for socket %d", strerror(errno), aString, sock);
} }
FUNC_EXIT_RC(errno); FUNC_EXIT_RC(errno);
return errno; return errno;
...@@ -170,7 +170,7 @@ int Socket_addSocket(int newSd) ...@@ -170,7 +170,7 @@ int Socket_addSocket(int newSd)
rc = Socket_setnonblocking(newSd); rc = Socket_setnonblocking(newSd);
} }
else else
Log(TRACE_MIN, -1, "addSocket: socket %d already in the list", newSd); Log(LOG_ERROR, -1, "addSocket: socket %d already in the list", newSd);
FUNC_EXIT_RC(rc); FUNC_EXIT_RC(rc);
return rc; return rc;
...@@ -640,10 +640,10 @@ int Socket_new(char* addr, int port, int* sock) ...@@ -640,10 +640,10 @@ int Socket_new(char* addr, int port, int* sock)
else else
rc = -1; rc = -1;
freeaddrinfo(result); freeaddrinfo(result);
} }
else else
Log(TRACE_MIN, -1, "getaddrinfo failed for addr %s with rc %d", addr, rc); Log(LOG_ERROR, -1, "getaddrinfo failed for addr %s with rc %d", addr, rc);
if (rc != 0) if (rc != 0)
Log(LOG_ERROR, -1, "%s is not a valid IP address", addr); Log(LOG_ERROR, -1, "%s is not a valid IP address", addr);
...@@ -658,7 +658,7 @@ int Socket_new(char* addr, int port, int* sock) ...@@ -658,7 +658,7 @@ int Socket_new(char* addr, int port, int* sock)
int opt = 1; int opt = 1;
if (setsockopt(*sock, SOL_SOCKET, SO_NOSIGPIPE, (void*)&opt, sizeof(opt)) != 0) if (setsockopt(*sock, SOL_SOCKET, SO_NOSIGPIPE, (void*)&opt, sizeof(opt)) != 0)
Log(TRACE_MIN, -1, "Could not set SO_NOSIGPIPE for socket %d", *sock); Log(LOG_ERROR, -1, "Could not set SO_NOSIGPIPE for socket %d", *sock);
#endif #endif
Log(TRACE_MIN, -1, "New socket %d for %s, port %d", *sock, addr, port); Log(TRACE_MIN, -1, "New socket %d for %s, port %d", *sock, addr, port);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment