--- mqtt/src/mqttd_calls.c 2012/06/20 14:51:38 1.2.2.24 +++ mqtt/src/mqttd_calls.c 2012/06/20 15:01:30 1.2.2.25 @@ -236,18 +236,18 @@ cmdSUBSCRIBE(void *srv, int len, void *arg) } /* add to db */ - for (i = 0; i < siz; i++) { + for (i = 0; i < siz; i++, subs[i].sub_ret = MQTT_QOS_DENY) { /* convert topic to sql search statement */ if (mqtt_sqlTopic(subs[i].sub_topic.msg_base, buf, sizeof buf) == -1) { ioDEBUG(5, "Error:: in db #%d - %s", mqtt_GetErrno(), mqtt_GetError()); - goto end; + continue; } if (call.WritePUB_subscribe(&cfg, pub, sess->sess_cid, mid, buf, sess->sess_user, sess->sess_addr, subs[i].sub_ret) > 0) { store = io_malloc(sizeof(struct tagStore)); if (!store) { ioSYSERR(0); - goto end; + continue; } else { store->st_msgid = mid; mqtt_subCopy(&store->st_subscr, &subs[i]); @@ -263,11 +263,9 @@ cmdSUBSCRIBE(void *srv, int len, void *arg) subs[i].sub_ret = MQTT_QOS_DENY; } else { ptr = realloc(store->st_subscr.sub_topic.msg_base, strlen(buf) + 1); - if (!ptr) { + if (!ptr) ioSYSERR(0); - - subs[i].sub_ret = MQTT_QOS_DENY; - } else { + else { store->st_subscr.sub_topic.msg_base = ptr; store->st_subscr.sub_topic.msg_len = strlen(buf) + 1; memcpy(store->st_subscr.sub_topic.msg_base, buf, @@ -280,8 +278,7 @@ cmdSUBSCRIBE(void *srv, int len, void *arg) subs[i].sub_ret = MQTT_QOS_PASS; } - } else - subs[i].sub_ret = MQTT_QOS_DENY; + } } /* send acknowledge */