MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / msg_list_check_msg

Function msg_list_check_msg

modules/msilo/ms_msg_list.c:160–211  ·  view source on GitHub ↗

* check if a message is in list */

Source from the content-addressed store, hash-verified

158 * check if a message is in list
159 */
160int msg_list_check_msg(msg_list ml, int mid)
161{
162 msg_list_el p0, p1;
163
164 if(!ml || mid==0)
165 goto errorx;
166
167 LM_DBG("checking msgid=%d\n", mid);
168
169 lock_get(&ml->sem_sent);
170
171 p0 = p1 = ml->lsent;
172 while(p0)
173 {
174 if(p0->msgid==mid)
175 goto exist;
176 p1 = p0;
177 p0 = p0->next;
178 }
179
180 p0 = msg_list_el_new();
181 if(!p0)
182 {
183 LM_ERR("failed to create new msg elem.\n");
184 goto error;
185 }
186 p0->msgid = mid;
187 p0->flag |= MS_MSG_SENT;
188
189 if(p1)
190 {
191 p1->next = p0;
192 p0->prev = p1;
193 goto done;
194 }
195
196 ml->lsent = p0;
197
198done:
199 ml->nrsent++;
200 lock_release(&ml->sem_sent);
201 LM_DBG("msg added to sent list.\n");
202 return MSG_LIST_OK;
203exist:
204 lock_release(&ml->sem_sent);
205 LM_DBG("msg already in sent list.\n");
206 return MSG_LIST_EXIST;
207error:
208 lock_release(&ml->sem_sent);
209errorx:
210 return MSG_LIST_ERR;
211}
212
213/**
214 * set flag for message with mid

Callers 2

m_dumpFunction · 0.85
m_send_ontimerFunction · 0.85

Calls 3

lock_getFunction · 0.85
msg_list_el_newFunction · 0.85
lock_releaseFunction · 0.85

Tested by

no test coverage detected