Example #1
0
cs_error_t
coroipcc_dispatch_put (hdb_handle_t handle)
{
	coroipc_response_header_t *header;
	struct ipc_instance *ipc_instance;
	cs_error_t res;
	char *addr;
	unsigned int read_idx;

	res = hdb_error_to_cs (hdb_handle_get_always (&ipc_hdb, handle, (void **)&ipc_instance));
	if (res != CS_OK) {
		return (res);
	}

retry_ipc_sem_wait:
	res = ipc_sem_wait (ipc_instance->control_buffer, SEMAPHORE_DISPATCH, ipc_instance->fd);
	if (res != CS_OK) {
		if (res == CS_ERR_TRY_AGAIN) {
			priv_change_send (ipc_instance);
			goto retry_ipc_sem_wait;
		} else {
			goto error_exit;
		}
	}

	addr = ipc_instance->dispatch_buffer;

	read_idx = ipc_instance->control_buffer->read;
	header = (coroipc_response_header_t *) &addr[read_idx];
	ipc_instance->control_buffer->read =
		((read_idx + header->size + 7) & 0xFFFFFFF8) %
			ipc_instance->dispatch_size;

	/*
	 * Put from dispatch get and also from this call's get
	 */
	res = CS_OK;
	
error_exit:
	hdb_handle_put (&ipc_hdb, handle);
	hdb_handle_put (&ipc_hdb, handle);

	return (res);
}
Example #2
0
cs_error_t
coroipcc_dispatch_put (hdb_handle_t handle)
{
#if _POSIX_THREAD_PROCESS_SHARED < 1
	struct sembuf sop;
#endif
	coroipc_response_header_t *header;
	struct ipc_instance *ipc_instance;
	int res;
	char *addr;
	unsigned int read_idx;

	res = hdb_error_to_cs (hdb_handle_get_always (&ipc_hdb, handle, (void **)&ipc_instance));
	if (res != CS_OK) {
		return (res);
	}
#if _POSIX_THREAD_PROCESS_SHARED > 0
retry_semwait:
	res = sem_wait (&ipc_instance->control_buffer->sem2);
	if (res == -1 && errno == EINTR) {
		goto retry_semwait;
	}
#else
	sop.sem_num = 2;
	sop.sem_op = -1;
	sop.sem_flg = 0;
retry_semop:
	res = semop (ipc_instance->semid, &sop, 1);
	if (res == -1 && errno == EINTR) {
		res = CS_ERR_TRY_AGAIN;
		goto error_exit;
	} else
	if (res == -1 && errno == EACCES) {
		priv_change_send (ipc_instance);
		goto retry_semop;
	} else
	if (res == -1) {
		res = CS_ERR_LIBRARY;
		goto error_exit;
	}
#endif

	addr = ipc_instance->dispatch_buffer;

	read_idx = ipc_instance->control_buffer->read;
	header = (coroipc_response_header_t *) &addr[read_idx];
	ipc_instance->control_buffer->read =
		(read_idx + header->size) % ipc_instance->dispatch_size;
	/*
	 * Put from dispatch get and also from this call's get
	 */
	res = CS_OK;
	
#if _POSIX_THREAD_PROCESS_SHARED < 1
error_exit:
#endif
	hdb_handle_put (&ipc_hdb, handle);
	hdb_handle_put (&ipc_hdb, handle);

	return (res);
}