コード例 #1
0
ファイル: notification.c プロジェクト: sardemff7/eventd
void
eventd_nd_notification_free(gpointer data)
{
    EventdNdNotification *self = data;

    if ( self->timeout > 0 )
        g_source_remove(self->timeout);

    if ( self->visible )
        g_queue_delete_link(self->queue->queue, self->link);
    else if ( self->event == NULL )
        g_list_free_1(self->link);
    else
        g_queue_delete_link(self->queue->wait_queue, self->link);

    if ( self->event == NULL )
        self->queue->more_notification = NULL;

    self->context->backend->surface_free(self->surface);
    _eventd_nd_notification_clean(self);

    if ( ( ! self->context->no_refresh ) && ( self->visible ) )
        _eventd_nd_notification_refresh_list(self->context, self->queue);

    g_free(self);
}
コード例 #2
0
ファイル: mgmt.c プロジェクト: DaisyPi/sensortag
bool mgmt_cancel_index(struct mgmt *mgmt, uint16_t index)
{
	GList *list, *next;

	if (!mgmt)
		return false;

	for (list = g_queue_peek_head_link(mgmt->request_queue); list;
								list = next) {
		struct mgmt_request *request = list->data;

		next = g_list_next(list);

		if (request->index != index)
			continue;

		g_queue_delete_link(mgmt->request_queue, list);

		destroy_request(request, NULL);
	}

	for (list = g_queue_peek_head_link(mgmt->reply_queue); list;
								list = next) {
		struct mgmt_request *request = list->data;

		next = g_list_next(list);

		if (request->index != index)
			continue;

		g_queue_delete_link(mgmt->reply_queue, list);

		destroy_request(request, NULL);
	}

	for (list = g_list_first(mgmt->pending_list); list; list = next) {
		struct mgmt_request *request = list->data;

		next = g_list_next(list);

		if (request->index != index)
			continue;

		mgmt->pending_list = g_list_delete_link(mgmt->pending_list,
									list);

		destroy_request(request, NULL);
	}

	return true;
}
コード例 #3
0
ファイル: mex-proxy.c プロジェクト: dudochkin-victor/mex
static void
mex_proxy_remove_content (MexProxy   *proxy,
                          MexContent *content)
{
  GObject *object;
  GList *to_add_link;

  MexProxyPrivate *priv = proxy->priv;

  object = g_hash_table_lookup (priv->content_to_object, content);
  if (object)
    {
      g_object_ref (object);

      g_signal_emit (proxy, signals[OBJECT_REMOVED], 0, content, object);

      g_object_weak_unref (object,
                           (GWeakNotify)mex_proxy_object_gone_cb,
                           proxy);
      g_hash_table_remove (priv->content_to_object, content);

      g_object_unref (object);

      priv->n_objects --;
    }
  else if ((to_add_link = g_hash_table_lookup (priv->to_add_hash, content)))
    {
      g_queue_delete_link (priv->to_add, to_add_link);
      g_hash_table_remove (priv->to_add_hash, content);
      g_object_unref (content);
    }
}
コード例 #4
0
ファイル: data.c プロジェクト: duxet/adium-facebook
GSList *
fb_data_take_messages(FbData *fata, FbId uid)
{
	FbApiMessage *msg;
	FbDataPrivate *priv;
	GList *l;
	GList *prev;
	GSList *msgs = NULL;

	g_return_val_if_fail(FB_IS_DATA(fata), NULL);
	priv = fata->priv;
	l = priv->msgs->tail;

	while (l != NULL) {
		msg = l->data;
		prev = l->prev;

		if (msg->uid == uid) {
			msgs = g_slist_prepend(msgs, msg);
			g_queue_delete_link(priv->msgs, l);
		}

		l = prev;
	}

	return msgs;
}
コード例 #5
0
void
tracker_priority_queue_remove_node (TrackerPriorityQueue *queue,
                                    GList                *node)
{
	guint i;

	g_return_if_fail (queue != NULL);

	/* Check if it is the first or last of a segment */
	for (i = 0; i < queue->segments->len; i++) {
		PrioritySegment *segment;

		segment = &g_array_index (queue->segments, PrioritySegment, i);

		if (segment->first_elem == node) {
			if (segment->last_elem == node)
				g_array_remove_index (queue->segments, i);
			else
				segment->first_elem = node->next;
			break;
		}

		if (segment->last_elem == node) {
			segment->last_elem = node->prev;
			break;
		}
	}

	g_queue_delete_link (&queue->queue, node);
}
コード例 #6
0
ファイル: connection.c プロジェクト: angel1991521/lighttpd2
void li_connection_reset(liConnection *con) {
	if (LI_CON_STATE_DEAD != con->state) {
		con->state = LI_CON_STATE_DEAD;

		con_iostream_close(con);
		li_stream_reset(&con->in);
		li_stream_reset(&con->out);

		li_vrequest_reset(con->mainvr, TRUE);
		li_stream_release(&con->in);
		li_stream_release(&con->out);

		con->info.keep_alive = TRUE;
		if (con->keep_alive_data.link) {
			g_queue_delete_link(&con->wrk->keep_alive_queue, con->keep_alive_data.link);
			con->keep_alive_data.link = NULL;
		}
		con->keep_alive_data.timeout = 0;
		con->keep_alive_data.max_idle = 0;
		li_event_stop(&con->keep_alive_data.watcher);
		con->keep_alive_requests = 0;
	}

	li_connection_update_io_wait(con);
	li_job_later(&con->wrk->loop.jobqueue, &con->job_reset);
}
コード例 #7
0
ファイル: Scheduler.cpp プロジェクト: wbrenna/xournalpp
Job * Scheduler::getNextJobUnlocked(bool onlyNotRender, bool * hasRenderJobs) {
	XOJ_CHECK_TYPE(Scheduler);

	Job * job = NULL;

	for (int i = JOB_PRIORITY_URGENT; i < JOB_N_PRIORITIES; i++) {
		if(onlyNotRender) {
			for(GList * l = this->jobQueue[i]->head; l != NULL; l = l->next) {
				job = (Job *) l->data;

				if(job->getType() != JOB_TYPE_RENDER) {
					g_queue_delete_link(this->jobQueue[i], l);
					return job;
				} else if(hasRenderJobs) {
					*hasRenderJobs = true;
				}
			}
		} else {
			job = (Job *) g_queue_pop_head(this->jobQueue[i]);
			if (job) {
				return job;
			}
		}
	}

	return NULL;
}
コード例 #8
0
ファイル: session.c プロジェクト: dmp0x7c5/test-repo
static void session_terminate_transfer(struct obc_session *session,
					struct obc_transfer *transfer,
					GError *gerr)
{
	struct pending_request *p = session->p;

	if (p == NULL || p->transfer != transfer) {
		GList *match;

		match = g_list_find_custom(session->queue->head, transfer,
						pending_transfer_cmptransfer);
		if (match == NULL)
			return;

		p = match->data;
		g_queue_delete_link(session->queue, match);
	} else
		session->p = NULL;

	obc_session_ref(session);

	if (p->func)
		p->func(session, p->transfer, gerr, p->data);

	pending_request_free(p);

	if (session->p == NULL)
		session_process_queue(session);

	obc_session_unref(session);
}
コード例 #9
0
ファイル: connection.c プロジェクト: angel1991521/lighttpd2
void li_connection_free(liConnection *con) {
	LI_FORCE_ASSERT(NULL == con->con_sock.data);
	LI_FORCE_ASSERT(LI_CON_STATE_DEAD == con->state);

	con->response_headers_sent = FALSE;
	con->expect_100_cont = FALSE;
	con->out_has_all_data = FALSE;

	li_server_socket_release(con->srv_sock);
	con->srv_sock = NULL;

	g_string_free(con->info.remote_addr_str, TRUE);
	li_sockaddr_clear(&con->info.remote_addr);
	g_string_free(con->info.local_addr_str, TRUE);
	li_sockaddr_clear(&con->info.local_addr);

	li_vrequest_free(con->mainvr);
	li_http_request_parser_clear(&con->req_parser_ctx);

	con->info.keep_alive = TRUE;
	if (con->keep_alive_data.link && con->wrk) {
		g_queue_delete_link(&con->wrk->keep_alive_queue, con->keep_alive_data.link);
		con->keep_alive_data.link = NULL;
	}
	con->keep_alive_data.timeout = 0;
	con->keep_alive_data.max_idle = 0;
	li_event_clear(&con->keep_alive_data.watcher);

	/* remove from timeout queue */
	li_waitqueue_remove(&con->wrk->io_timeout_queue, &con->io_timeout_elem);

	li_job_clear(&con->job_reset);

	g_slice_free(liConnection, con);
}
コード例 #10
0
static void
ToolsCorePoolCancel(guint id)
{
   GList *taskLnk;
   WorkerTask *task = NULL;
   WorkerTask search = { id, };

   g_return_if_fail(id != 0);

   g_mutex_lock(gState.lock);
   if (!gState.active) {
      goto exit;
   }

   taskLnk = g_queue_find_custom(gState.workQueue, &search, ToolsCorePoolCompareTask);
   if (taskLnk != NULL) {
      task = taskLnk->data;
      g_queue_delete_link(gState.workQueue, taskLnk);
   }

exit:
   g_mutex_unlock(gState.lock);

   if (task != NULL) {
      if (task->srcId > 0) {
         g_source_remove(task->srcId);
      } else {
         ToolsCorePoolDestroyTask(task);
      }
   }
}
コード例 #11
0
ファイル: empathy-tp-chat.c プロジェクト: james-w/empathy
void
empathy_tp_chat_acknowledge_message (EmpathyTpChat *chat,
				     EmpathyMessage *message) {
	EmpathyTpChatPriv *priv = GET_PRIV (chat);
	GArray *message_ids;
	GList *m;
	guint id;

	g_return_if_fail (EMPATHY_IS_TP_CHAT (chat));
	g_return_if_fail (priv->ready);

	if (empathy_message_get_sender (message) == priv->user)
		goto out;

	message_ids = g_array_sized_new (FALSE, FALSE, sizeof (guint), 1);

	id = empathy_message_get_id (message);
	g_array_append_val (message_ids, id);
	acknowledge_messages (chat, message_ids);
	g_array_free (message_ids, TRUE);

out:
	m = g_queue_find (priv->pending_messages_queue, message);
	g_assert (m != NULL);
	g_queue_delete_link (priv->pending_messages_queue, m);
	g_object_unref (message);
}
コード例 #12
0
void
nautilus_thumbnail_remove_from_queue (const char *file_uri)
{
	GList *node;
	
#ifdef DEBUG_THUMBNAILS
	g_message ("(Remove from queue) Locking mutex\n");
#endif
	pthread_mutex_lock (&thumbnails_mutex);

	/*********************************
	 * MUTEX LOCKED
	 *********************************/

	if (thumbnails_to_make_hash) {
		node = g_hash_table_lookup (thumbnails_to_make_hash, file_uri);
		
		if (node && node->data != currently_thumbnailing) {
			g_hash_table_remove (thumbnails_to_make_hash, file_uri);
			free_thumbnail_info (node->data);
			g_queue_delete_link ((GQueue *)&thumbnails_to_make, node);
		}
	}
	
	/*********************************
	 * MUTEX UNLOCKED
	 *********************************/
	
#ifdef DEBUG_THUMBNAILS
	g_message ("(Remove from queue) Unlocking mutex\n");
#endif
	pthread_mutex_unlock (&thumbnails_mutex);
}
コード例 #13
0
ファイル: network-socket.c プロジェクト: hewei-chn/resurgence
/**
 * write data to the socket
 *
 */
static network_socket_retval_t network_socket_write_send(network_socket *con, int send_chunks) {
	/* send the whole queue */
	GList *chunk;

	if (send_chunks == 0) return NETWORK_SOCKET_SUCCESS;

	for (chunk = con->send_queue->chunks->head; chunk; ) {
		GString *s = chunk->data;
		gssize len;

		g_assert(con->send_queue->offset < s->len);

		if (con->socket_type == SOCK_STREAM) {
			len = send(con->fd, s->str + con->send_queue->offset, s->len - con->send_queue->offset, 0);
		} else {
			len = sendto(con->fd, s->str + con->send_queue->offset, s->len - con->send_queue->offset, 0, &(con->dst->addr.common), con->dst->len);
		}
		if (-1 == len) {
			switch (errno) {
			case E_NET_WOULDBLOCK:
			case EAGAIN:
				return NETWORK_SOCKET_WAIT_FOR_EVENT;
			case EPIPE:
			case E_NET_CONNRESET:
			case E_NET_CONNABORTED:
				/** remote side closed the connection */
				return NETWORK_SOCKET_ERROR;
			default:
				g_message("%s: send(%s, %"G_GSIZE_FORMAT") failed: %s", 
						G_STRLOC, 
						con->dst->name->str, 
						s->len - con->send_queue->offset, 
						g_strerror(errno));
				return NETWORK_SOCKET_ERROR;
			}
		} else if (len == 0) {
			return NETWORK_SOCKET_ERROR;
		}

		con->send_queue->offset += len;

		if (con->send_queue->offset == s->len) {
			g_string_free(s, TRUE);
			
			g_queue_delete_link(con->send_queue->chunks, chunk);
			con->send_queue->offset = 0;

			if (send_chunks > 0 && --send_chunks == 0) break;

			chunk = con->send_queue->chunks->head;
		} else {
			return NETWORK_SOCKET_WAIT_FOR_EVENT;
		}
	}

	return NETWORK_SOCKET_SUCCESS;
}
コード例 #14
0
void
gst_insert_bin_remove (GstInsertBin * self, GstElement * element,
    GstInsertBinCallback callback, gpointer user_data)
{
  GstObject *parent;

  g_return_if_fail (GST_IS_ELEMENT (element));

  parent = gst_element_get_parent (element);

  if (parent) {
    gboolean is_parent;

    is_parent = (parent == GST_OBJECT_CAST (self));
    gst_object_unref (parent);

    if (!is_parent) {
      if (callback)
        callback (self, element, FALSE, user_data);
      return;
    }
  } else {
    GList *item;
    struct ChangeData *data = NULL;

    GST_OBJECT_LOCK (self);
    for (item = self->priv->change_queue.head; item; item = item->next) {
      data = item->data;

      if (data->element == element) {
        if (data->action == GST_INSERT_BIN_ACTION_ADD)
          g_queue_delete_link (&self->priv->change_queue, item);
        break;
      }
      data = NULL;
    }
    GST_OBJECT_UNLOCK (self);

    if (data) {
      gst_object_ref (element);
      gst_insert_bin_change_data_complete (self, data, TRUE);
      if (callback)
        callback (self, element, TRUE, user_data);
      gst_object_unref (element);
    } else {
      if (callback)
        callback (self, element, FALSE, user_data);
    }
    return;
  }

  gst_object_ref (element);

  gst_insert_bin_add_operation (self, element, GST_INSERT_BIN_ACTION_REMOVE,
      NULL, FALSE, callback, user_data);
}
コード例 #15
0
void
mex_download_queue_cancel (MexDownloadQueue *queue,
                           gpointer          id)
{
  MexDownloadQueuePrivate *priv;
  DQTask *task = id;
  GList *l;

  g_return_if_fail (MEX_IS_DOWNLOAD_QUEUE (queue));
  g_return_if_fail (id);

  priv = queue->priv;

  MEX_NOTE (DOWNLOAD_QUEUE, "cancelling download: %s", task->any.uri);

  l = g_queue_find (priv->queue, task);
  if (l)
    {
      /* Make sure our last-local link stays valid */
      if (priv->last_local == l)
        priv->last_local = l->prev;

      mex_download_queue_free (task);
      g_queue_delete_link (priv->queue, l);

      g_object_notify (G_OBJECT (queue), "queue-length");

      return;
    }

  switch (task->type)
    {
    case MEX_DQ_TYPE_SOUP:
      soup_session_cancel_message (priv->session,
                                   task->soup.message,
                                   SOUP_STATUS_CANCELLED);
      break;

    case MEX_DQ_TYPE_GIO:
      g_cancellable_cancel (task->gio.cancellable);
      break;

    case MEX_DQ_TYPE_CACHED:
      if (task->cached.source_id)
        g_source_remove (task->cached.source_id);
      task->cached.source_id = 0;

      mex_download_queue_free (task);
      break;

    default:
      g_warning ("Unknown download type cancelled! %d", task->type);
      break;
    }
}
コード例 #16
0
ファイル: sms.c プロジェクト: AndriusA/ofono
static void sms_tx_queue_remove_entry(struct ofono_sms *sms, GList *entry_list,
					enum message_state tx_state)
{
	struct tx_queue_entry *entry = entry_list->data;
	struct ofono_modem *modem = __ofono_atom_get_modem(sms->atom);

	g_queue_delete_link(sms->txq, entry_list);

	DBG("%p", entry);

	if (entry->cb)
		entry->cb(tx_state == MESSAGE_STATE_SENT, entry->data);

	if (entry->flags & OFONO_SMS_SUBMIT_FLAG_RECORD_HISTORY) {
		enum ofono_history_sms_status hs;

		switch(tx_state) {
		case MESSAGE_STATE_SENT:
			hs = OFONO_HISTORY_SMS_STATUS_SUBMITTED;
			break;
		case MESSAGE_STATE_FAILED:
			hs = OFONO_HISTORY_SMS_STATUS_SUBMIT_FAILED;
			break;
		case MESSAGE_STATE_CANCELLED:
			hs = OFONO_HISTORY_SMS_STATUS_SUBMIT_CANCELLED;
			break;
		default:
			ofono_error("Unexpected sms state %d", tx_state);
			goto done;
		}

		__ofono_history_sms_send_status(modem, &entry->uuid,
								time(NULL), hs);
	}

	if (entry->flags & OFONO_SMS_SUBMIT_FLAG_EXPOSE_DBUS) {
		struct message *m;

		sms_tx_backup_free(sms->imsi, entry->id, entry->flags,
					ofono_uuid_to_str(&entry->uuid));

		m = g_hash_table_lookup(sms->messages, &entry->uuid);

		if (m != NULL) {
			message_set_state(m, tx_state);
			g_hash_table_remove(sms->messages, &entry->uuid);
			message_emit_removed(m,
					OFONO_MESSAGE_MANAGER_INTERFACE);
			message_dbus_unregister(m);
		}
	}

done:
	tx_queue_entry_destroy(entry);
}
コード例 #17
0
ファイル: utilities.c プロジェクト: stevesbrain/rmlint
gint rm_util_queue_foreach_remove(GQueue *queue, RmQRFunc func, gpointer user_data) {
    gint removed = 0;

    for(GList *iter = queue->head, *next = NULL; iter; iter = next) {
        next = iter->next;
        if(func(iter->data, user_data)) {
            g_queue_delete_link(queue, iter);
            ++removed;
        }
    }
    return removed;
}
コード例 #18
0
ファイル: mgmt.c プロジェクト: DaisyPi/sensortag
bool mgmt_cancel(struct mgmt *mgmt, unsigned int id)
{
	struct mgmt_request *request;
	GList *list;

	if (!mgmt || !id)
		return false;

	list = g_queue_find_custom(mgmt->request_queue, GUINT_TO_POINTER(id),
							compare_request_id);
	if (list) {
		request = list->data;
		g_queue_delete_link(mgmt->request_queue, list);
		goto done;
	}

	list = g_queue_find_custom(mgmt->reply_queue, GUINT_TO_POINTER(id),
							compare_request_id);
	if (list) {
		request = list->data;
		g_queue_delete_link(mgmt->reply_queue, list);
		goto done;
	}

	list = g_list_find_custom(mgmt->pending_list, GUINT_TO_POINTER(id),
							compare_request_id);
	if (!list)
		return false;

	request = list->data;

	mgmt->pending_list = g_list_delete_link(mgmt->pending_list, list);

done:
	destroy_request(request, NULL);

	wakeup_writer(mgmt);

	return true;
}
コード例 #19
0
ファイル: fm-list.c プロジェクト: afilmore/libfmcore
void fm_list_remove (gpointer list, gpointer data)
{
    GList *l =  ( (GQueue*)list)->head;
    for (; l; l=l->next)
    {
        if (l->data == data)
        {
            FM_LIST (list)->funcs->item_unref (data);
            break;
        }
    }
    if (l)
        g_queue_delete_link ( (GQueue*)data, l);
}
コード例 #20
0
ファイル: sync-mgr.c プロジェクト: break123/seafile
void
seaf_sync_manager_cancel_sync_task (SeafSyncManager *mgr,
                                    const char *repo_id)
{
    SyncInfo *info;
    SyncTask *task;
    GList *link;

    /* Cancel any pending tasks for this repo on the queue. */
    link = g_queue_find_custom (mgr->sync_tasks,
                                repo_id, compare_sync_task);
    if (link) {
        task = link->data;
        sync_task_free (task);
        g_queue_delete_link (mgr->sync_tasks, link);
    }

    /* Cancel running task. */
    info = g_hash_table_lookup (mgr->sync_infos, repo_id);
    if (!info || !info->in_sync)
        return;

    g_assert (info->current_task != NULL);
    task = info->current_task;

    switch (task->state) {
    case SYNC_STATE_FETCH:
        seaf_transfer_manager_cancel_task (seaf->transfer_mgr,
                                           task->tx_id,
                                           TASK_TYPE_DOWNLOAD);
        transition_sync_state (task, SYNC_STATE_CANCEL_PENDING);
        break;
    case SYNC_STATE_UPLOAD:
        seaf_transfer_manager_cancel_task (seaf->transfer_mgr,
                                           task->tx_id,
                                           TASK_TYPE_UPLOAD);
        transition_sync_state (task, SYNC_STATE_CANCEL_PENDING);
        break;
    case SYNC_STATE_COMMIT:
    case SYNC_STATE_INIT:
    case SYNC_STATE_MERGE:
        transition_sync_state (task, SYNC_STATE_CANCEL_PENDING);
        break;
    case SYNC_STATE_CANCEL_PENDING:
        break;
    default:
        g_assert (0);
    }
}
コード例 #21
0
ファイル: connection.c プロジェクト: angel1991521/lighttpd2
static void li_connection_reset2(liConnection *con) {
	con->response_headers_sent = FALSE;
	con->expect_100_cont = FALSE;
	con->out_has_all_data = FALSE;

	con_iostream_close(con);

	li_server_socket_release(con->srv_sock);
	con->srv_sock = NULL;
	con->info.is_ssl = FALSE;
	con->info.aborted = FALSE;
	con->info.out_queue_length = 0;

	li_stream_reset(&con->in);
	li_stream_reset(&con->out);

	li_vrequest_reset(con->mainvr, FALSE);

	li_http_request_parser_reset(&con->req_parser_ctx);

	g_string_truncate(con->info.remote_addr_str, 0);
	li_sockaddr_clear(&con->info.remote_addr);
	g_string_truncate(con->info.local_addr_str, 0);
	li_sockaddr_clear(&con->info.local_addr);

	con->info.keep_alive = TRUE;
	if (con->keep_alive_data.link) {
		g_queue_delete_link(&con->wrk->keep_alive_queue, con->keep_alive_data.link);
		con->keep_alive_data.link = NULL;
	}
	con->keep_alive_data.timeout = 0;
	con->keep_alive_data.max_idle = 0;
	li_event_stop(&con->keep_alive_data.watcher);
	con->keep_alive_requests = 0;

	/* reset stats */
	con->info.stats.bytes_in = G_GUINT64_CONSTANT(0);
	con->info.stats.bytes_in_5s = G_GUINT64_CONSTANT(0);
	con->info.stats.bytes_in_5s_diff = G_GUINT64_CONSTANT(0);
	con->info.stats.bytes_out = G_GUINT64_CONSTANT(0);
	con->info.stats.bytes_out_5s = G_GUINT64_CONSTANT(0);
	con->info.stats.bytes_out_5s_diff = G_GUINT64_CONSTANT(0);
	con->info.stats.last_avg = 0;

	/* remove from timeout queue */
	li_waitqueue_remove(&con->wrk->io_timeout_queue, &con->io_timeout_elem);

	li_job_reset(&con->job_reset);
}
コード例 #22
0
ファイル: grl-tmdb.c プロジェクト: GNOME/grilo-plugins
static void remove_request (ResolveClosure *closure,
                            GrlTmdbRequest *request)
{
  GList *it;

  for (it = closure->pending_requests->head; it; it = it->next) {
    PendingRequest *const pending_request = it->data;

    if (pending_request->request == request) {
      g_queue_delete_link (closure->pending_requests, it);
      pending_request_free (pending_request);
      break;
    }
  }
}
コード例 #23
0
ファイル: gqueue.c プロジェクト: antono/glib
/**
 * g_queue_remove:
 * @queue: a #GQueue
 * @data: data to remove.
 * 
 * Removes the first element in @queue that contains @data. 
 * 
 * Return value: %TRUE if @data was found and removed from @queue
 *
 * Since: 2.4
 **/
gboolean
g_queue_remove (GQueue        *queue,
		gconstpointer  data)
{
  GList *link;
  
  g_return_val_if_fail (queue != NULL, FALSE);

  link = g_list_find (queue->head, data);

  if (link)
    g_queue_delete_link (queue, link);

  return (link != NULL);
}
コード例 #24
0
ファイル: navqueue.c プロジェクト: Aligorith/geany
/* Remove all elements with the given filename */
void navqueue_remove_file(const gchar *filename)
{
	GList *match;

	if (filename == NULL)
		return;

	while ((match = g_queue_find_custom(navigation_queue, filename, find_by_filename)))
	{
		g_free(match->data);
		g_queue_delete_link(navigation_queue, match);
	}

	adjust_buttons();
}
コード例 #25
0
ファイル: openslide-cache.c プロジェクト: Markus-PP/openslide
static void hash_destroy_value(gpointer data) {
  struct _openslide_cache_value *value = data;

  // remove the item from the list
  g_queue_delete_link(value->cache->list, value->link);

  // decrement the total size
  value->cache->total_size -= value->entry->size;
  g_assert(value->cache->total_size >= 0);

  // unref the entry
  _openslide_cache_entry_unref(value->entry);

  // free the value
  g_slice_free(struct _openslide_cache_value, value);
}
コード例 #26
0
/**
 *******************************************************************************
 * @brief Remove a serial (token) from the queue and map.
 *
 * @attention locks the serial info lock
 *
 * @param  serial_info  IN  serial info
 * @param  serial       IN  serial (token) to remove
 *******************************************************************************
 */
void
_LSTransportSerialRemove(_LSTransportSerial *serial_info, LSMessageToken serial)
{
    SERIAL_INFO_LOCK(&serial_info->lock);

    _LSTransportSerialMapEntry *map_entry = g_hash_table_lookup(serial_info->map, &serial);

    if (map_entry)
    {
        _LSTransportSerialListItem *item = (_LSTransportSerialListItem*)map_entry->serial_list_item->data;
        g_queue_delete_link(serial_info->queue, map_entry->serial_list_item);
        _LSTransportSerialListItemFree(item);
        g_hash_table_remove(serial_info->map, &serial);
    }

    SERIAL_INFO_UNLOCK(&serial_info->lock);
}
コード例 #27
0
ファイル: cache_mng.c プロジェクト: bfleischer/riofs
// removes file from local storage
void cache_mng_remove_file (CacheMng *cmng, fuse_ino_t ino)
{
    struct _CacheEntry *entry;
    char path[PATH_MAX];

    entry = g_hash_table_lookup (cmng->h_entries, GUINT_TO_POINTER (ino));
    if (entry) {
        cmng->size -= range_length (entry->avail_range);
        g_queue_delete_link (cmng->q_lru, entry->ll_lru);
        g_hash_table_remove (cmng->h_entries, GUINT_TO_POINTER (ino));
        cache_mng_file_name (cmng, path, sizeof (path), ino);
        unlink (path);
        LOG_debug (CMNG_LOG, INO_H"Entry is removed", INO_T (ino));
    } else {
        LOG_debug (CMNG_LOG, INO_H"Entry not found", INO_T (ino));
    }
}
コード例 #28
0
void vfs_thumbnail_loader_cancel_all_requests( VFSDir* dir, gboolean is_big )
{
    GList* l;
    VFSThumbnailLoader* loader;
    ThumbnailRequest* req;

    if( G_UNLIKELY( (loader=dir->thumbnail_loader) ) )
    {
        vfs_async_task_lock( loader->task );
        /* g_debug( "TRY TO CANCEL REQUESTS!!" ); */
        for( l = loader->queue->head; l;  )
        {
            req = (ThumbnailRequest*)l->data;
            --req->n_requests[ is_big ? LOAD_BIG_THUMBNAIL : LOAD_SMALL_THUMBNAIL ];

            if( req->n_requests[0]  <= 0 && req->n_requests[1] <= 0 )   /* nobody needs this */
            {
                GList* next = l->next;
                g_queue_delete_link( loader->queue, l );
                l = next;
            }
            else
                l = l->next;
        }

        if( g_queue_get_length( loader->queue ) == 0 )
        {
            /* g_debug( "FREE LOADER IN vfs_thumbnail_loader_cancel_all_requests!" ); */
            vfs_async_task_unlock( loader->task );
            loader->dir->thumbnail_loader = NULL;
            
            /* FIXME: added idle_handler = 0 to prevent idle_handler being
             * removed in vfs_thumbnail_loader_free - BUT causes a segfault
             * in vfs_async_task_lock ??
             * If source is removed here or in vfs_thumbnail_loader_free
             * it causes a "GLib-CRITICAL **: Source ID N was not found when
             * attempting to remove it" warning.  Such a source ID is always
             * the one added in thumbnail_loader_thread at the "add2" comment. */
            //loader->idle_handler = 0;
            
            vfs_thumbnail_loader_free( loader );
            return;
        }
        vfs_async_task_unlock( loader->task );
    }
}
コード例 #29
0
EXPORT_C
#endif

gboolean
gst_data_queue_drop_head (GstDataQueue * queue, GType type)
{
  gboolean res = FALSE;
  GList *item;
  GstDataQueueItem *leak = NULL;

  g_return_val_if_fail (GST_IS_DATA_QUEUE (queue), FALSE);

  GST_DEBUG ("queue:%p", queue);

  GST_DATA_QUEUE_MUTEX_LOCK (queue);
  for (item = g_queue_peek_head_link (queue->queue); item; item = item->next) {
    GstDataQueueItem *tmp = (GstDataQueueItem *) item->data;

    if (G_TYPE_CHECK_INSTANCE_TYPE (tmp->object, type)) {
      leak = tmp;
      break;
    }
  }

  if (!leak)
    goto done;

  g_queue_delete_link (queue->queue, item);

  if (leak->visible)
    queue->cur_level.visible--;
  queue->cur_level.bytes -= leak->size;
  queue->cur_level.time -= leak->duration;

  leak->destroy (leak);

  res = TRUE;

done:
  GST_DATA_QUEUE_MUTEX_UNLOCK (queue);

  GST_DEBUG ("queue:%p , res:%d", queue, res);

  return res;
}
コード例 #30
0
static void
entry_added_cb (RhythmDB *db,
		RhythmDBEntry *entry,
		RhythmDBImportJob *job)
{
	const char *uri;
	GList *link;

	uri = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_LOCATION);

	g_mutex_lock (&job->priv->lock);
	link = g_queue_find_custom (job->priv->processing, uri, (GCompareFunc) g_strcmp0);

	if (link != NULL) {
		const char *details;
		RhythmDBEntryType *entry_type;

		entry_type = rhythmdb_entry_get_entry_type (entry);

		job->priv->processed++;

		if (entry_type == job->priv->entry_type) {
			job->priv->imported++;
			g_signal_emit (job, signals[ENTRY_ADDED], 0, entry);
		}
		rb_debug ("got entry %s; %d imported, %d processed", uri, job->priv->imported, job->priv->processed);

		/* if it's an import error with missing plugins, add it to the retry list */
		details = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_COMMENT);
		if (entry_type == job->priv->error_type &&
		    (details != NULL && details[0] != '\0')) {
			rb_debug ("entry %s is an import error with missing plugin details: %s", uri, details);
			job->priv->retry_entries = g_slist_prepend (job->priv->retry_entries, rhythmdb_entry_ref (entry));
		}

		if (job->priv->status_changed_id == 0) {
			job->priv->status_changed_id = g_idle_add ((GSourceFunc) emit_status_changed, job);
		}

		g_queue_delete_link (job->priv->processing, link);
		maybe_start_more (job);
	}
	g_mutex_unlock (&job->priv->lock);
}