Exemplo n.º 1
0
Arquivo: ipcs.c Projeto: ip1981/libqb
qb_ipcs_connection_t *
qb_ipcs_connection_first_get(struct qb_ipcs_service * s)
{
	struct qb_ipcs_connection *c;
	struct qb_list_head *iter;

	if (qb_list_empty(&s->connections)) {
		return NULL;
	}
	iter = s->connections.next;

	c = qb_list_entry(iter, struct qb_ipcs_connection, list);
	qb_ipcs_connection_ref(c);

	return c;
}
Exemplo n.º 2
0
static void read_messages (int sock, char* atmost_str)
{
	struct qb_list_head * list;
	log_entry_t *entry;
	int atmost = atoi (atmost_str);
	int packed = 0;
	ssize_t rc;

	if (atmost == 0)
		atmost = 1;
	if (atmost > (HOW_BIG_AND_BUF / LOG_STR_SIZE))
		atmost = (HOW_BIG_AND_BUF / LOG_STR_SIZE);

	big_and_buf[0] = '\0';

	for (list = msg_log_head.next;
		(!qb_list_empty (&msg_log_head) && packed < atmost); ) {

		entry = qb_list_entry (list, log_entry_t, list);

		strcat (big_and_buf, entry->log);
		packed++;

		list = list->next;
		qb_list_del (&entry->list);
		free (entry);

		total_stored_msgs--;
	}
	if (packed == 0) {
		strcpy (big_and_buf, "None");
	} else {
		if ((total_stored_msgs % 1000) == 0) {
			qb_log(LOG_INFO, "sending %d; total_stored_msgs:%d; len:%d",
				packed, total_stored_msgs, (int)strlen (big_and_buf));
		}
	}
	rc = send (sock, big_and_buf, strlen (big_and_buf), 0);
	assert(rc == strlen (big_and_buf));
}
Exemplo n.º 3
0
Arquivo: loop.c Projeto: fjrti/libqb
static void
qb_loop_run_level(struct qb_loop_level *level)
{
	struct qb_loop_item *job;
	int32_t processed = 0;

Ill_have_another:

	if (!qb_list_empty(&level->job_head)) {
		job = qb_list_first_entry(&level->job_head, struct qb_loop_item, list);
		qb_list_del(&job->list);
		qb_list_init(&job->list);
		job->source->dispatch_and_take_back(job, level->priority);
		level->todo--;
		processed++;
		if (level->l->stop_requested) {
			return;
		}
		if (processed < level->to_process) {
			goto Ill_have_another;
		}
	}