Exemplo n.º 1
0
/**
 * Calculate the number of bytes that will be stored by `marshal_server`
 * 
 * On failure the program should `abort()` or exit by other means.
 * However it should not be possible for this function to fail.
 * 
 * @return  The number of bytes that will be stored by `marshal_server`
 */
size_t
marshal_server_size(void)
{
	size_t rc = 2 * sizeof(int) + sizeof(uint32_t);
	rc += mds_message_marshal_size(&received);
	rc += colour_list_marshal_size(&colours);
	return rc;
}
Exemplo n.º 2
0
/**
 * Calculate the number of bytes that will be stored by `marshal_server`
 * 
 * On failure the program should `abort()` or exit by other means.
 * However it should not be possible for this function to fail.
 * 
 * @return  The number of bytes that will be stored by `marshal_server`
 */
size_t marshal_server_size(void)
{
  size_t rc = 6 * sizeof(int) + sizeof(uint32_t) + sizeof(ssize_t);
  rc += sizeof(struct stat);
  rc += PATH_MAX * sizeof(char);
  rc += mds_message_marshal_size(&received);
  return rc;
}
Exemplo n.º 3
0
/**
 * Marshal server implementation specific data into a buffer
 * 
 * @param   state_buf  The buffer for the marshalled data
 * @return             Non-zero on error
 */
int
marshal_server(char *state_buf)
{
	buf_set_next(state_buf, int, MDS_COLOUR_VARS_VERSION);
	buf_set_next(state_buf, int, connected);
	buf_set_next(state_buf, uint32_t, message_id);

	mds_message_marshal(&received, state_buf);
	state_buf += mds_message_marshal_size(&received) / sizeof(char*);

	colour_list_marshal(&colours, state_buf);

	mds_message_destroy(&received);
	colour_list_destroy(&colours);
	return 0;
}
Exemplo n.º 4
0
/**
 * Calculate the number of bytes that will be stored by `marshal_server`
 * 
 * On failure the program should `abort()` or exit by other means.
 * However it should not be possible for this function to fail.
 * 
 * @return  The number of bytes that will be stored by `marshal_server`
 */
size_t
marshal_server_size(void)
{
	size_t i, rc = 2 * sizeof(int) + sizeof(uint32_t) + 4 * sizeof(size_t);
	hash_entry_t *entry;
	ssize_t node;
	char *command;
	size_t len;
	client_list_t *list;
	slave_t *slave;

	rc += mds_message_marshal_size(&received);
	rc += linked_list_marshal_size(&slave_list);

	foreach_hash_table_entry (reg_table, i, entry) {
		command = (void *)entry->key;
		len = strlen(command) + 1;
		list = (void *)entry->value;

		rc += len + sizeof(size_t) + client_list_marshal_size(list);
	}
Exemplo n.º 5
0
/**
 * Unmarshal server implementation specific data and update the servers state accordingly
 * 
 * On critical failure the program should `abort()` or exit by other means.
 * That is, do not let `reexec_failure_recover` run successfully, if it unrecoverable
 * error has occurred or one severe enough that it is better to simply respawn.
 * 
 * @param   state_buf  The marshalled data that as not been read already
 * @return             Non-zero on error
 */
int
unmarshal_server(char *state_buf)
{
	int stage = 0;

	/* buf_get_next(state_buf, int, MDS_COLOUR_VARS_VERSION); */
	buf_next(state_buf, int, 1);
	buf_get_next(state_buf, int, connected);
	buf_get_next(state_buf, uint32_t, message_id);

	fail_if (mds_message_unmarshal(&received, state_buf));
	state_buf += mds_message_marshal_size(&received) / sizeof(char*);
	stage++;

	fail_if (colour_list_unmarshal(&colours, state_buf));

	return 0;
fail:
	xperror(*argv);
	if (stage >= 0) mds_message_destroy(&received);
	if (stage >= 1) colour_list_destroy(&colours);
	return -1;
}
Exemplo n.º 6
0
/**
 * Calculate the number of bytes that will be stored by `marshal_server`
 * 
 * On failure the program should `abort()` or exit by other means.
 * However it should not be possible for this function to fail.
 * 
 * @return  The number of bytes that will be stored by `marshal_server`
 */
size_t
marshal_server_size(void)
{
	return 2 * sizeof(int) + sizeof(uint32_t) + mds_message_marshal_size(&received);
}