Exemple #1
0
static void swwd_entry_delete(dsme_swwd_entry_t * proc)
{
  if (proc) {
      if (proc->kill_timer) {
          dsme_destroy_timer(proc->kill_timer);
          dsme_log(LOG_NOTICE, "killing process (pid: %i)", proc->pid);
          kill(proc->pid, SIGKILL); 
      }
      endpoint_free(proc->client);
      free(proc);
  }
}
Exemple #2
0
/**
 * s3_serverpool_free(SP):
 * Free the server pool ${SP}.
 */
void
s3_serverpool_free(struct s3_serverpool * SP)
{
	S3_SERVERPOOL S = (S3_SERVERPOOL)SP;

	/* Delete endpoints. */
	while (serverpool_getsize(S) > 0)
		endpoint_free(S, 0);

	/* Free the elastic array. */
	serverpool_free(S);
}
Exemple #3
0
void url_free(url_t *target) {
	if (!target) {
		return;
	}

	mutable_string_free(&(target->url));
	endpoint_free(&(target->endpoint));
	uri_free(&(target->uri));
	qs_free(&(target->query_string));

	return;
}
Exemple #4
0
/**
 * s3_serverpool_pick(SP):
 * Pick an address from ${SP} and return it.  The caller is responsible for
 * freeing the address.
 */
struct sock_addr *
s3_serverpool_pick(struct s3_serverpool * SP)
{
	S3_SERVERPOOL S = (S3_SERVERPOOL)SP;
	struct timeval tv;
	struct timeval * tvo;
	struct sock_addr * sa;
	size_t i;

	/* If we have no endpoints, fail. */
	if (serverpool_getsize(S) == 0)
		goto err0;

	/* Delete expired endpoints; count down to avoid missing anything. */
	if (monoclock_get(&tv))
		goto err0;
	for (i = serverpool_getsize(S); i > 0; i--) {
		/* Is the EOL still in the future? */
		tvo = &serverpool_get(S, i - 1)->eol;
		if ((tvo->tv_sec > tv.tv_sec) ||
		    ((tvo->tv_sec == tv.tv_sec) &&
		     (tvo->tv_usec > tv.tv_usec)))
			continue;

		/* Is this the last remaining endpoint? */
		if (serverpool_getsize(S) == 1)
			continue;

		/* Delete this endpoint. */
		endpoint_free(S, i - 1);
	}

	/* Pick a (non-cryptographically) random endpoint. */
	i = (size_t)rand() % serverpool_getsize(S);

	/* Make a copy of the address. */
	if ((sa = sock_addr_dup(serverpool_get(S, i)->sa)) == NULL)
		goto err0;

	/* Return the address. */
	return (sa);

err0:
	/* Failure! */
	return (NULL);
}