MCPcopy Create free account
hub / github.com/acl-dev/acl / queue_push

Function queue_push

lib_fiber/c/src/common/queue.c:231–273  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

229}
230
231int queue_push(QUEUE *que, void *data)
232{
233 QUEUE_ITEM *qi;
234 int status;
235
236 if (que == NULL) {
237 msg_fatal("%s: aqueue null", __FUNCTION__);
238 }
239
240 qi = calloc(1, sizeof(QUEUE_ITEM));
241 qi->data = data;
242
243 status = pthread_mutex_lock(&que->lock);
244 if (status != 0) {
245 msg_error("%s: lock error(%s)", __FUNCTION__, last_serror());
246 free(qi);
247 que->error = QUEUE_ERR_LOCK;
248 return -1;
249 }
250
251 if (que->first == NULL) {
252 que->first = qi;
253 } else {
254 que->last->next = qi;
255 }
256
257 que->last = qi;
258 que->qlen++;
259
260 status = pthread_mutex_unlock(&que->lock);
261 if (status != 0) {
262 msg_error("%s: unlock error(%s)", __FUNCTION__, last_serror());
263 return -1;
264 }
265
266 status = pthread_cond_signal(&que->cond);
267 if (status != 0) {
268 msg_error("%s: cond signal error(%s)", __FUNCTION__, last_serror());
269 return -1;
270 }
271
272 return 0;
273}
274
275int queue_qlen(QUEUE* que)
276{

Callers

nothing calls this directly

Calls 7

msg_fatalFunction · 0.85
callocFunction · 0.85
pthread_mutex_lockFunction · 0.85
freeFunction · 0.85
pthread_mutex_unlockFunction · 0.85
msg_errorFunction · 0.70
last_serrorFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…