示例#1
0
static void xfer_timeout(struct timer_list *t)
{
	struct floppy_state *fs = from_timer(fs, t, timeout);
	struct swim3 __iomem *sw = fs->swim3;
	struct dbdma_regs __iomem *dr = fs->dma;
	unsigned long flags;
	int n;

	swim3_dbg("* xfer timeout, state=%d\n", fs->state);

	spin_lock_irqsave(&swim3_lock, flags);
	fs->timeout_pending = 0;
	out_le32(&dr->control, RUN << 16);
	/* We must wait a bit for dbdma to stop */
	for (n = 0; (in_le32(&dr->status) & ACTIVE) && n < 1000; n++)
		udelay(1);
	out_8(&sw->intr_enable, 0);
	out_8(&sw->control_bic, WRITE_SECTORS | DO_ACTION);
	out_8(&sw->select, RELAX);
	swim3_err("Timeout %sing sector %ld\n",
	       (rq_data_dir(fs->cur_req)==WRITE? "writ": "read"),
	       (long)blk_rq_pos(fs->cur_req));
	swim3_end_request(fs, BLK_STS_IOERR, 0);
	fs->state = idle;
	start_request(fs);
	spin_unlock_irqrestore(&swim3_lock, flags);
}
示例#2
0
static gboolean send_data(GIOChannel *channel, GIOCondition cond,
						gpointer user_data)
{
	struct web_session *session = user_data;

	if (cond & (G_IO_NVAL | G_IO_ERR | G_IO_HUP)) {
		session->send_watch = 0;
		return FALSE;
	}

	if (process_send_buffer(session) == TRUE)
		return TRUE;

	if (process_send_file(session) == TRUE)
		return TRUE;

	if (session->request_started == FALSE) {
		session->request_started = TRUE;
		start_request(session);
	} else if (session->more_data == TRUE)
		process_next_chunk(session);

	process_send_buffer(session);

	if (session->body_done == TRUE) {
		session->send_watch = 0;
		return FALSE;
	}

	return TRUE;
}
示例#3
0
/*---------------------------------------------------------------------------*/
int
http_socket_get(struct http_socket *s,
                const char *url,
                int64_t pos,
                uint64_t length,
                http_socket_callback_t callback,
                void *callbackptr)
{
  init();

  strncpy(s->url, url, sizeof(s->url));
  s->pos = pos;
  s->length = length;
  s->postdata = NULL;
  s->postdatalen = 0;
  s->timeout_timer_started = 0;
  PT_INIT(&s->pt);
  tcp_socket_register(&s->s, s,
                      s->inputbuf, sizeof(s->inputbuf),
                      s->outputbuf, sizeof(s->outputbuf),
                      input, event);

  s->callback = callback;
  s->callbackptr = callbackptr;

  list_add(socketlist, s);

  return start_request(s);
}
示例#4
0
/*---------------------------------------------------------------------------*/
int
http_socket_post(struct http_socket *s,
                 const char *url,
                 const void *postdata,
                 uint16_t postdatalen,
                 const char *content_type,
                 http_socket_callback_t callback,
                 void *callbackptr)
{
  init();

  strncpy(s->url, url, sizeof(s->url));
  s->pos = 0;
  s->length = 0;
  s->postdata = postdata;
  s->postdatalen = postdatalen;
  s->content_type = content_type;
  s->timeout_timer_started = 0;
  PT_INIT(&s->pt);
  tcp_socket_register(&s->s, s,
                      s->inputbuf, sizeof(s->inputbuf),
                      s->outputbuf, sizeof(s->outputbuf),
                      input, event);

  s->callback = callback;
  s->callbackptr = callbackptr;

  list_add(socketlist, s);

  return start_request(s);
}
示例#5
0
static void settle_timeout(struct timer_list *t)
{
	struct floppy_state *fs = from_timer(fs, t, timeout);
	struct swim3 __iomem *sw = fs->swim3;
	unsigned long flags;

	swim3_dbg("* settle timeout, state=%d\n", fs->state);

	spin_lock_irqsave(&swim3_lock, flags);
	fs->timeout_pending = 0;
	if (swim3_readbit(fs, SEEK_COMPLETE)) {
		out_8(&sw->select, RELAX);
		fs->state = locating;
		act(fs);
		goto unlock;
	}
	out_8(&sw->select, RELAX);
	if (fs->settle_time < 2*HZ) {
		++fs->settle_time;
		set_timeout(fs, 1, settle_timeout);
		goto unlock;
	}
	swim3_err("%s", "Seek settle timeout\n");
	swim3_end_request(fs, BLK_STS_IOERR, 0);
	fs->state = idle;
	start_request(fs);
 unlock:
	spin_unlock_irqrestore(&swim3_lock, flags);
}
示例#6
0
文件: swim3.c 项目: ANFS/ANFS-kernel
static void release_drive(struct floppy_state *fs)
{
	unsigned long flags;

	spin_lock_irqsave(&fs->lock, flags);
	fs->state = idle;
	start_request(fs);
	spin_unlock_irqrestore(&fs->lock, flags);
}
示例#7
0
static void release_drive(struct floppy_state *fs)
{
	unsigned long flags;

	swim3_dbg("%s", "-> release drive\n");

	spin_lock_irqsave(&swim3_lock, flags);
	fs->state = idle;
	start_request(fs);
	spin_unlock_irqrestore(&swim3_lock, flags);
}
示例#8
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(http_socket_process, ev, data)
{
  PROCESS_BEGIN();

  while(1) {

    PROCESS_WAIT_EVENT();

    if(ev == resolv_event_found && data != NULL) {
      struct http_socket *s;
      const char *name = data;
      /* Either found a hostname, or not. We need to go through the
	 list of http sockets and figure out to which connection this
	 reply corresponds, then either restart the HTTP get, or kill
	 it (if no hostname was found). */
      for(s = list_head(socketlist);
          s != NULL;
          s = list_item_next(s)) {
        char host[MAX_HOSTLEN];
        if(s->did_tcp_connect) {
          /* We already connected, ignored */
        } else if(parse_url(s->url, host, NULL, NULL) &&
            strcmp(name, host) == 0) {
          if(resolv_lookup(name, NULL) == RESOLV_STATUS_CACHED) {
            /* Hostname found, restart get. */
            start_request(s);
          } else {
            /* Hostname not found, kill connection. */
            call_callback(s, HTTP_SOCKET_HOSTNAME_NOT_FOUND, NULL, 0);
            removesocket(s);
          }
        }
      }
    } else if(ev == PROCESS_EVENT_TIMER) {
      struct http_socket *s;
      struct etimer *timeout_timer = data;
      /*
       * A socket time-out has occurred. We need to go through the list of HTTP
       * sockets and figure out to which socket this timer event corresponds,
       * then close this socket.
       */
      for(s = list_head(socketlist);
          s != NULL;
          s = list_item_next(s)) {
        if(timeout_timer == &s->timeout_timer && s->timeout_timer_started) {
          tcp_socket_close(&s->s);
          break;
        }
      }
    }
  }

  PROCESS_END();
}
示例#9
0
文件: main.c 项目: WongTai/snippets
int main(int argc, char **argv)
{
	struct ProxyStruct proxystruct;
	int s, f, size, rv, parsed_headers=0;
	char recv_buf[8192];

	/* Make sure stuff sane */
	pre_check();

	proxystruct=parseuri(GETENV("REQUEST_URI"));

#ifdef UGLY_DEBUG
	fprintf(stderr, "URL:  %s\nURI:  %s\nFile:  %s\n",
		proxystruct.request_url, proxystruct.request_uri, proxystruct.file);
	fprintf(stderr, "URL Structure:\n\tHost:  %s\n\tPort:  %d\n\tURI:  %s\n",
		proxystruct.url.host, proxystruct.url.port, proxystruct.url.req);
	fprintf(stderr, proxystruct.url.httpreq);
#endif /* UGLY_DEBUG */

	/* Make sure we allow access to this host and port (and what not) */
	if(check_auth(proxystruct)==FALSE) {
		do_error(403, "text/plain", "You are not authorized to do get this.");
	} else {
		ensurepath(proxystruct.file);
		f=open(proxystruct.tmpfile, O_WRONLY|O_CREAT|O_EXCL, 0644);
		if(f<0) {
			perror(proxystruct.tmpfile);
		}

		s=start_request(proxystruct);

		while( (size=recv(s, recv_buf, sizeof(recv_buf), 0)) > 0) {
			if(parsed_headers==0) {
				parsed_headers=parse_headers(recv_buf, &size);
			}

			rv=write(1, recv_buf, size);
			assert(rv==size);

			if(f>=0) {
				rv=write(f, recv_buf, size);
				assert(rv==size);
			}
		}

		/* Save it */
		if(rename(proxystruct.tmpfile, proxystruct.file)<0) {
			perror(proxystruct.file);
		}
	}

	return(0);
}
示例#10
0
文件: swim3.c 项目: ANFS/ANFS-kernel
static void do_fd_request(struct request_queue * q)
{
	int i;

	for(i=0; i<floppy_count; i++) {
		struct floppy_state *fs = &floppy_states[i];
		if (fs->mdev->media_bay &&
		    check_media_bay(fs->mdev->media_bay) != MB_FD)
			continue;
		start_request(fs);
	}
}
示例#11
0
文件: swim3.c 项目: sarnobat/knoppix
static void do_fd_request(request_queue_t * q)
{
	int i;
	for(i=0;i<floppy_count;i++)
	{
		if (floppy_states[i].media_bay &&
			check_media_bay(floppy_states[i].media_bay, MB_FD))
			continue;
		start_request(&floppy_states[i]);
	}
	sti();
}
示例#12
0
文件: twi.c 项目: russells/dclock
/**
 * Wait here until the interrupt state machine tells us it's finished the
 * TWI requests.  Reject any further TWI requests.
 */
static QState twiBusyState(struct TWI *me)
{
	uint8_t index;
	uint8_t sreg;
	struct TWIRequest **requestp;

	switch (Q_SIG(me)) {

	case Q_ENTRY_SIG:
		//SERIALSTR("TWI > twiBusyState\r\n");
		start_request(me);
		return Q_HANDLED();

	case Q_EXIT_SIG:
		//SERIALSTR("TWI < twiBusyState\r\n");
		sreg = SREG;
		cli();
		me->requests[0] = 0;
		me->requests[1] = 0;
		me->requestIndex = 0;
		SREG = sreg;
		return Q_HANDLED();

	case TWI_REQUEST_SIGNAL:
		SERIALSTR("TWI got excess TWI_REQUEST_SIGNAL\r\n");
		requestp = (struct TWIRequest **)((uint16_t)Q_PAR(me));
		if (requestp[0] && requestp[0]->signal) {
			requestp[0]->status = TWI_QUEUE_FULL;
			post(requestp[0]->qactive, requestp[0]->signal,
			     (QParam)((uint16_t)requestp[0]));
		}
		if (requestp[1] && requestp[1]->signal) {
			requestp[1]->status = TWI_QUEUE_FULL;
			post(requestp[1]->qactive, requestp[1]->signal,
			     (QParam)((uint16_t)requestp[1]));
		}
		return Q_HANDLED();

	case TWI_REPLY_SIGNAL:
		index = (uint8_t) Q_PAR(me);
		//SERIALSTR("TWI got TWI_REPLY_SIGNAL index=");
		//serial_send_int(index);
		//SERIALSTR("\r\n");
		post(me->requests[index]->qactive, me->requests[index]->signal,
		     (QParam)((uint16_t)(me->requests[index])));
		return Q_HANDLED();

	case TWI_FINISHED_SIGNAL:
		return Q_TRAN(twiState);

	}
	return Q_SUPER(twiState);
}
示例#13
0
static void do_fd_request(request_queue_t * q)
{
	int i;
	for(i=0;i<floppy_count;i++)
	{
#ifdef CONFIG_PMAC_MEDIABAY
		if (floppy_states[i].media_bay &&
			check_media_bay(floppy_states[i].media_bay, MB_FD))
			continue;
#endif /* CONFIG_PMAC_MEDIABAY */
		start_request(&floppy_states[i]);
	}
}
示例#14
0
void connection::do_connect()
{
    std::lock_guard<std::mutex> lock(_mutex);
    if (_stopped) return;
    auto self = shared_from_this();
    asio::ip::tcp::endpoint ep{asio::ip::address::from_string("127.0.0.1"), 80};
    start_request();
    _sock.async_connect(ep, [this, self](const asio::error_code& ec) {
        if (!ec) {
            do_write();
        }
    });
}
示例#15
0
static void
new_connection (SoupSocket *listner, SoupSocket *sock, gpointer user_data)
{
	SoupServer *server = user_data;
	SoupServerPrivate *priv = SOUP_SERVER_GET_PRIVATE (server);
	SoupClientContext *client;

	client = soup_client_context_new (server, g_object_ref (sock));
	priv->client_socks = g_slist_prepend (priv->client_socks, sock);
	g_signal_connect (sock, "disconnected",
			  G_CALLBACK (socket_disconnected), server);
	start_request (server, client);
}
示例#16
0
static void client_thread(void *arg) 
{
    List *reqh;
    unsigned long i;
    long succeeded, failed;
    HTTPCaller *caller;
    char buf[1024];
    long in_queue;
    Counter *counter = NULL;

    caller = arg;
    succeeded = 0;
    failed = 0;
    reqh = gwlist_create();
    sprintf(buf, "%ld", (long) gwthread_self());
    http_header_add(reqh, "X-Thread", buf);
    if (auth_username != NULL && auth_password != NULL)
	http_add_basic_auth(reqh, auth_username, auth_password);

    in_queue = 0;
    counter = counter_create();
    
    for (;;) {
	    i = counter_increase(counter);
	    if (i >= max_requests)
	    	goto receive_rest;
	    start_request(caller, reqh, i);
	    if (interval > 0)
            gwthread_sleep(interval);
        ++in_queue;
	    if (receive_reply(caller) == -1)
	       ++failed;
    	else
	    	++succeeded;
	    --in_queue;
    }

receive_rest:
    while (in_queue > 0) {
	if (receive_reply(caller) == -1)
	    ++failed;
	else
	    ++succeeded;
    	--in_queue;
    }

    counter_destroy(counter);
    http_destroy_headers(reqh);
    http_caller_destroy(caller);
    info(0, "This thread: %ld succeeded, %ld failed.", succeeded, failed);
}
示例#17
0
/*---------------------------------------------------------------------------*/
int
http_socket_get(struct http_socket *s,
                const char *url,
                http_socket_connection_t connection,
                http_socket_callback_t callback,
                void *callbackptr)
{
  init(s, url, callback, callbackptr);

  s->method = HTTP_GET;
  s->connection_policy = connection;

  return start_request(s);
}
示例#18
0
文件: swim3.c 项目: ANFS/ANFS-kernel
static void seek_timeout(unsigned long data)
{
	struct floppy_state *fs = (struct floppy_state *) data;
	struct swim3 __iomem *sw = fs->swim3;

	fs->timeout_pending = 0;
	out_8(&sw->control_bic, DO_SEEK);
	out_8(&sw->select, RELAX);
	out_8(&sw->intr_enable, 0);
	printk(KERN_ERR "swim3: seek timeout\n");
	swim3_end_request_cur(-EIO);
	fs->state = idle;
	start_request(fs);
}
示例#19
0
int main(int argc, char **argv)
{
	int ret, last, total;
	struct timeval now, prev;

	/* Set max cache size */
	cm_max_cache_size = 256;

	/* Process args, including getting the URL list */
	read_url_file(URL_FILE);

	/* Initialize modules - Scheduler and MM */
	g_thread_init(NULL);
	ret = nkn_scheduler_init(NULL, NKN_SCHED_START_MMTHREADS);
	if (ret < 0)
		err(0, "Failed to initialize scheduler\n");
	cache_manager_init();
	DM_init();

	/* Register our test module - using Chunk Mgr for now
	ret = nkn_task_register_task_type(mmt_mod, mmt_input, mmt_output, mmt_cleanup);
	if (ret)
		err(0, "failed to register mmt module\n");
	*/

	pthread_mutex_init(&lock, NULL);
	pthread_cond_init(&cv, NULL);

	/* Issue Requests */
	gettimeofday(&prev, NULL);
	last = 0;
	total = 0;
	while (1) {
		start_request();
		total++;
                gettimeofday(&now, NULL);
                if (now.tv_sec > prev.tv_sec) {
                        printf("%d reqs\n", total-last);
                        last = total;
                        prev = now;
                }
	}
	return 0;
}
示例#20
0
文件: swim3.c 项目: ANFS/ANFS-kernel
static void scan_timeout(unsigned long data)
{
	struct floppy_state *fs = (struct floppy_state *) data;
	struct swim3 __iomem *sw = fs->swim3;

	fs->timeout_pending = 0;
	out_8(&sw->control_bic, DO_ACTION | WRITE_SECTORS);
	out_8(&sw->select, RELAX);
	out_8(&sw->intr_enable, 0);
	fs->cur_cyl = -1;
	if (fs->retries > 5) {
		swim3_end_request_cur(-EIO);
		fs->state = idle;
		start_request(fs);
	} else {
		fs->state = jogging;
		act(fs);
	}
}
示例#21
0
static void seek_timeout(struct timer_list *t)
{
	struct floppy_state *fs = from_timer(fs, t, timeout);
	struct swim3 __iomem *sw = fs->swim3;
	unsigned long flags;

	swim3_dbg("* seek timeout, state=%d\n", fs->state);

	spin_lock_irqsave(&swim3_lock, flags);
	fs->timeout_pending = 0;
	out_8(&sw->control_bic, DO_SEEK);
	out_8(&sw->select, RELAX);
	out_8(&sw->intr_enable, 0);
	swim3_err("%s", "Seek timeout\n");
	swim3_end_request(fs, BLK_STS_IOERR, 0);
	fs->state = idle;
	start_request(fs);
	spin_unlock_irqrestore(&swim3_lock, flags);
}
示例#22
0
/*---------------------------------------------------------------------------*/
int http_socket_post(struct http_socket *s, const char *url,
                      const uint8_t *postdata,
                      uint16_t postdatalen,
                      const char *content_type,
                      http_socket_connection_t connection,
                      http_socket_callback_t callback,
                      void *callbackptr)
{
  init(s, url, callback, callbackptr);

  s->method = HTTP_POST;
  s->connection_policy = connection;
  s->request_data = postdata;
  s->request_datalen = postdatalen;
  s->request_dataptr = 0;
  s->post_headers_sent = 0;
  strncpy(s->content_type, content_type, sizeof(s->content_type));

  return start_request(s);
}
示例#23
0
/*---------------------------------------------------------------------------*/
int
http_socket_get(struct http_socket *s,
                const char *url,
                int64_t pos,
                uint64_t length,
                http_socket_callback_t callback,
                void *callbackptr)
{
  initialize_socket(s);
  strncpy(s->url, url, sizeof(s->url));
  s->pos = pos;
  s->length = length;
  s->callback = callback;
  s->callbackptr = callbackptr;

  s->did_tcp_connect = 0;

  list_add(socketlist, s);

  return start_request(s);
}
示例#24
0
static int on_body(h2o_http1client_t *client, const char *errstr)
{
    if (errstr != NULL && errstr != h2o_http1client_error_is_eos) {
        fprintf(stderr, "%s\n", errstr);
        exit(1);
        return -1;
    }

    fwrite(client->sock->input->bytes, 1, client->sock->input->size, stdout);
    h2o_buffer_consume(&client->sock->input, client->sock->input->size);

    if (errstr == h2o_http1client_error_is_eos) {
        if (--cnt_left != 0) {
            /* next attempt */
            h2o_mempool_clear(&pool);
            start_request(client->ctx);
        }
    }

    return 0;
}
示例#25
0
文件: request.c 项目: cnh/kurma
// Called when all of the processing on the outer requests has finished.
static int outer_done(struct request *r)
{
	DEBUG("[%d] Request received, processing it.\n", r->fd);

	// The request has finished sending all of its data. Process it.
	r->data[r->outer_index] = NULL;
	r->buffer = &r->buffer_char;
	r->buffer_len = 0;
	r->inner_index = 0;
	r->inner_len = 0;
	r->string_len = 0;

	// Check to see that the user sent a command.
	if (r->data == NULL || r->outer_len < 1 || r->data[0][0] == NULL) {
		ERROR("[%d] Command is missing from request.\n", r->fd);
		initd_response_protocol_error(r);
	} else if (!strncmp(r->data[0][0], "CHROOT", 7)) {
		chroot_request(r);
	} else if (!strncmp(r->data[0][0], "SETHOSTNAME", 12)) {
		sethostname_request(r);
	} else if (!strncmp(r->data[0][0], "EXEC", 5)) {
		exec_request(r);
	} else if (!strncmp(r->data[0][0], "START", 6)) {
		start_request(r);
	} else if (!strncmp(r->data[0][0], "MOUNT", 6)) {
		mount_request(r);
	} else if (!strncmp(r->data[0][0], "STATUS", 7)) {
		status_request(r);
	} else if (!strncmp(r->data[0][0], "WAIT", 5)) {
		wait_request(r);
	} else {
		// This is an unknown request!
		ERROR("[%d] Unknown command: %s\n", r->fd, r->data[0][0]);
		initd_response_protocol_error(r);
	}

	// Let the reader know that this request is done processing.
	return 1;
}
示例#26
0
static void
request_finished (SoupMessage *msg, SoupClientContext *client)
{
	SoupServer *server = client->server;
	SoupSocket *sock = client->sock;

	g_signal_emit (server,
		       msg->status_code == SOUP_STATUS_IO_ERROR ?
		       signals[REQUEST_ABORTED] : signals[REQUEST_FINISHED],
		       0, msg, client);

	soup_client_context_cleanup (client);
	if (soup_socket_is_connected (sock) && soup_message_is_keepalive (msg)) {
		/* Start a new request */
		start_request (server, client);
	} else {
		soup_socket_disconnect (sock);
		soup_client_context_unref (client);
	}
	g_object_unref (msg);
	g_object_unref (sock);
}
示例#27
0
文件: swim3.c 项目: ANFS/ANFS-kernel
static void xfer_timeout(unsigned long data)
{
	struct floppy_state *fs = (struct floppy_state *) data;
	struct swim3 __iomem *sw = fs->swim3;
	struct dbdma_regs __iomem *dr = fs->dma;
	int n;

	fs->timeout_pending = 0;
	out_le32(&dr->control, RUN << 16);
	/* We must wait a bit for dbdma to stop */
	for (n = 0; (in_le32(&dr->status) & ACTIVE) && n < 1000; n++)
		udelay(1);
	out_8(&sw->intr_enable, 0);
	out_8(&sw->control_bic, WRITE_SECTORS | DO_ACTION);
	out_8(&sw->select, RELAX);
	printk(KERN_ERR "swim3: timeout %sing sector %ld\n",
	       (rq_data_dir(fd_req)==WRITE? "writ": "read"),
	       (long)blk_rq_pos(fd_req));
	swim3_end_request_cur(-EIO);
	fs->state = idle;
	start_request(fs);
}
示例#28
0
int main(int argc, char **argv)
{
    h2o_http1client_ctx_t ctx = {
        NULL,
        &zero_timeout,
        &io_timeout
    };

    if (argc != 2) {
        fprintf(stderr, "Usage: %s <url>\n", argv[0]);
        return 1;
    }
    url = argv[1];

    h2o_mempool_init(&pool);

    /* setup context */
#if H2O_USE_LIBUV
    ctx.loop = uv_loop_new();
#else
    ctx.loop = h2o_evloop_create();
#endif
    h2o_timeout_init(ctx.loop, &zero_timeout, 0);
    h2o_timeout_init(ctx.loop, &io_timeout, 5000); /* 5 seconds */

    /* setup the first request */
    start_request(&ctx);

    while (cnt_left != 0) {
#if H2O_USE_LIBUV
        uv_run(ctx.loop, UV_RUN_ONCE);
#else
        h2o_evloop_run(ctx.loop);
#endif
    }

    return 0;
}
示例#29
0
文件: swim3.c 项目: ANFS/ANFS-kernel
static void settle_timeout(unsigned long data)
{
	struct floppy_state *fs = (struct floppy_state *) data;
	struct swim3 __iomem *sw = fs->swim3;

	fs->timeout_pending = 0;
	if (swim3_readbit(fs, SEEK_COMPLETE)) {
		out_8(&sw->select, RELAX);
		fs->state = locating;
		act(fs);
		return;
	}
	out_8(&sw->select, RELAX);
	if (fs->settle_time < 2*HZ) {
		++fs->settle_time;
		set_timeout(fs, 1, settle_timeout);
		return;
	}
	printk(KERN_ERR "swim3: seek settle timeout\n");
	swim3_end_request_cur(-EIO);
	fs->state = idle;
	start_request(fs);
}
示例#30
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(http_socket_process, ev, data)
{
  PROCESS_BEGIN();

  while(1) {

    PROCESS_WAIT_EVENT();

    if(ev == resolv_event_found && data != NULL) {
      struct http_socket *s;
      const char *name = data;
      /* Either found a hostname, or not. We need to go through the
   list of http sockets and figure out to which connection this
   reply corresponds, then either restart the HTTP get, or kill
   it (if no hostname was found). */
      for(s = list_head(socketlist);
    s != NULL;
    s = list_item_next(s)) {
  char host[MAX_HOSTLEN];
  if(parse_url(s->url, host, NULL, NULL) &&
     strcmp(name, host) == 0) {
    if(resolv_lookup(name, 0) == RESOLV_STATUS_CACHED) {
      /* Hostname found, restart request. */
      start_request(s);
    } else {
      /* Hostname not found, kill connection. */
            call_callback(s, HTTP_SOCKET_HOSTNAME_NOT_FOUND, NULL, 0);
            removesocket(s);
    }
  }
      }
    }
  }

  PROCESS_END();
}