|
|
@@ -258,6 +258,7 @@ static void listener_on_pkt_threadpool(threadpool_t *threadpool, void *arg)
|
|
|
if (pkt)
|
|
|
iobuffer_dec_ref(pkt);
|
|
|
|
|
|
+ sp_dbg_debug("%s: dec ref", __FUNCTION__);
|
|
|
sp_var_listener_dec_ref(listener); //@
|
|
|
|
|
|
sp_svc_pop_runserial_context(svc);
|
|
|
@@ -274,8 +275,10 @@ static int listener_on_pkt(sp_svc_t *svc,int epid, int svc_id, int pkt_type, int
|
|
|
iobuffer_write_head(pkt, IOBUF_T_I4, &svc_id, 0);
|
|
|
iobuffer_write_head(pkt, IOBUF_T_I4, &epid, 0);
|
|
|
iobuffer_write_head(pkt, IOBUF_T_PTR, &listener, 0);
|
|
|
+ sp_dbg_debug("%s: inc ref", __FUNCTION__);
|
|
|
sp_var_listener_inc_ref(listener);//@
|
|
|
if (threadpool_queue_workitem(sp_svc_get_threadpool(svc), listener->strand, &listener_on_pkt_threadpool, pkt) < 0) {
|
|
|
+ sp_dbg_debug("%s: dec ref", __FUNCTION__);
|
|
|
sp_var_listener_dec_ref(listener);//@
|
|
|
iobuffer_dec_ref(pkt);
|
|
|
}
|
|
|
@@ -293,16 +296,17 @@ int sp_var_listener_create(sp_svc_t *svc, const char *key, sp_var_on_change on_c
|
|
|
listener->strand = strand_create();
|
|
|
listener->key = _strdup(key);
|
|
|
listener->svc = svc;
|
|
|
+ REF_COUNT_INIT(&listener->ref_cnt); // BugFix for @ [Gifur@202051]
|
|
|
*p_listener = listener;
|
|
|
|
|
|
- sp_dbg_debug("create listener %llu for key %s (%llu)." , listener, listener->key, (void*)listener->key);
|
|
|
+ sp_dbg_debug("create listener %llu for key %s (%u)." , listener, listener->key, (void*)listener->key);
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
static void __sp_var_listener_destroy(sp_var_listener_t *listener)
|
|
|
{
|
|
|
strand_destroy(listener->strand);
|
|
|
- sp_dbg_debug("free listener %llu for key %s (%llu).", listener, listener->key, (void*)listener->key);
|
|
|
+ sp_dbg_debug("free listener %llu for key %s (%u).", listener, listener->key, (void*)listener->key);
|
|
|
free(listener->key);
|
|
|
free(listener);
|
|
|
}
|
|
|
@@ -310,6 +314,7 @@ IMPLEMENT_REF_COUNT_MT_STATIC(sp_var_listener, sp_var_listener_t, ref_cnt, __sp_
|
|
|
|
|
|
void sp_var_listener_destroy(sp_var_listener_t *listener)
|
|
|
{
|
|
|
+ sp_dbg_debug("%s: dec ref", __FUNCTION__);
|
|
|
sp_var_listener_dec_ref(listener);
|
|
|
}
|
|
|
|
|
|
@@ -322,7 +327,7 @@ int sp_var_listener_subscribe(sp_var_listener_t *listener)
|
|
|
return Error_Duplication;
|
|
|
|
|
|
pkt = iobuffer_create(-1, -1);
|
|
|
-
|
|
|
+ //TODO: int is dangerous.
|
|
|
sp_svc_add_pkt_handler(listener->svc, (int)listener, SP_PKT_VAR, &listener_on_pkt, listener);
|
|
|
|
|
|
iobuffer_write(pkt, IOBUF_T_STR, listener->key, -1);
|
|
|
@@ -418,7 +423,7 @@ static int daemon_on_pkt(sp_svc_t *svc,int epid, int svc_id, int pkt_type, int p
|
|
|
daemon_lock(daemon);
|
|
|
for (i = 0; i < daemon->arr_listener->nelts; ++i) {
|
|
|
var_listener_entry* tmp = ARRAY_IDX(daemon->arr_listener, i, var_listener_entry*);
|
|
|
- if (_stricmp(tmp->key, "*")==0 || _stricmp(key, tmp->key) == 0) {
|
|
|
+ if (_stricmp(tmp->key, "*") == 0 || _stricmp(key, tmp->key) == 0) {
|
|
|
iobuffer_t *copy_pkt;
|
|
|
if (i == daemon->arr_listener->nelts-1) {
|
|
|
copy_pkt = pkt;
|