Ejemplo n.º 1
0
static void
call_created (Event_Type et, Object *obj, Any_Type reg_arg, Any_Type arg)
{
    Call *c = (Call *) obj;

    assert (et == EV_CALL_NEW && object_is_call (obj));

    if (method_len > 0)
        call_set_method (c, param.method, method_len);

    if (random_extra_len > 0 && (rand() % 2))
        call_append_request_header (c, random_extra, random_extra_len);
    else if (extra_len > 0)
        call_append_request_header (c, extra, extra_len);
}
Ejemplo n.º 2
0
static void
call_issue (Event_Type et, Object *obj, Any_Type regarg, Any_Type callarg)
{
  Call_Private_Data *cpriv;
  Sess_Private_Data *priv;
  Sess *sess;
  Call *call;

  assert (et == EV_CALL_ISSUE && object_is_call (obj));
  call = (Call *) obj;
  cpriv = CALL_PRIVATE_DATA (call);

  if (cpriv->cookie_present)
    /* don't do anything if cookie has been set already */
    return;

  sess = session_get_sess_from_call (call);
  priv = SESS_PRIVATE_DATA (sess);

  if (priv->cookie_len > 0)
    {
      if (DBG > 1)
	fprintf (stderr, "call_issue.%ld: inserting `%s'\n",
		 call->id, priv->cookie);
      cpriv->cookie_present = 1;
      memcpy (cpriv->cookie, priv->cookie, priv->cookie_len + 1);
      call_append_request_header (call, cpriv->cookie, priv->cookie_len);
    }
}
Ejemplo n.º 3
0
static void
issue_calls (Sess *sess, Sess_Private_Data *priv)
{
  int i, to_create, retval, n;
  const char *method_str;
  Call *call;
  REQ *req;

  /* Mimic browser behavior of fetching html object, then a couple of
     embedded objects: */

  to_create = 1;
  if (priv->num_calls_in_this_burst > 0)
    to_create = priv->current_burst->num_reqs - priv->num_calls_in_this_burst;

  n = session_max_qlen (sess) - session_current_qlen (sess);
  if (n < to_create)
    to_create = n;

  priv->num_calls_in_this_burst += to_create;

  for (i = 0; i < to_create; ++i)
    {
      call = call_new ();
      if (!call)
	{
	  sess_failure (sess);
	  return;
	}

      /* fill in the new call: */
      req = priv->current_req;
      if (req == NULL)
	panic ("%s: internal error, requests ran past end of burst\n",
	       prog_name);

      method_str = call_method_name[req->method];
      call_set_method (call, method_str, strlen (method_str));
      call_set_uri (call, req->uri, req->uri_len);
      if (req->contents_len > 0)
	{
	  /* add "Content-length:" header and contents, if necessary: */
	  call_append_request_header (call, req->extra_hdrs,
				      req->extra_hdrs_len);
	  call_set_contents (call, req->contents, req->contents_len);
	}
      priv->current_req = req->next;

      if (DBG > 0)
	fprintf (stderr, "%s: accessing URI `%s'\n", prog_name, req->uri);

      retval = session_issue_call (sess, call);
      call_dec_ref (call);

      if (retval < 0)
	return;
    }
}
Ejemplo n.º 4
0
static void
issue_calls (Sess *sess, Sess_Private_Data *priv)
{
  int  retval;
  const char *method_str;
  Call *call;
  REQ *req;
  
  call = call_new ();
  if (!call)
  {
	sess_failure (sess);
	return;
  }

  req = priv->current_req;
  if (req == NULL)
	panic ("%s: internal error, requests ran past end of session\n",
	       prog_name);
  method_str = call_method_name[req->method];
  call_set_method (call, method_str, strlen (method_str));
  call_set_uri (call, req->uri, req->uri_len);
  if (req->contents_len > 0)
  {
	 /* add "Content-length:" header and contents, if necessary: */
	  call_append_request_header (call, req->extra_hdrs,
				      req->extra_hdrs_len);
	  call_set_contents (call, req->contents, req->contents_len);
  }

  if (DBG > 0)
	fprintf (stderr, "%s: accessing URI `%s'\n", prog_name, req->uri);
        retval = session_issue_call (sess, call);
	
	call_dec_ref (call);

      if (retval < 0)
	return;

}
Ejemplo n.º 5
0
static void
set_uri (Event_Type et, Call * c)
{
  char *uri;
  int uri_len, did_wrap = 0, range_len, input_len;
  const char *input_line;

  assert (et == EV_CALL_NEW && object_is_call (c));

  do
    {
      if (fcurrent >= fend)
		{
    	  if (did_wrap)
			panic ("%s: %s does not contain any valid URIs\n",
			   prog_name, param.wrangelog.file);
		  did_wrap = 1;

		  /* We reached the end of the uri list so wrap around to the
			 beginning.  If not looping, also ask for the test to stop
			 as soon as possible (the current request will still go
			 out, but httperf won't wait for its reply to show up).  */
		  fcurrent = fbase;
		  if (!param.wrangelog.do_loop)
			core_exit ();

		}
        input_line = fcurrent;

        input_len = strlen (fcurrent);


      /*****************************/
//        int j;
//        while (input_line[j] != ' ') {
//        	j++;
//        	if (j > input_len)
//        	{
//        		panic ("Error: illegal format for wrangelog\n");
//        	}
//        }
//
//        uri_len = j;

        uri_len = strcspn( input_line, " ");

        uri = fcurrent;

        /***************************/
        int range_size = input_len - uri_len - 1;

        char prefix_extra_hdrs[] = "Range: bytes=";
		size_t prefix_size = strlen(prefix_extra_hdrs);
		char suffix_extra_hdrs[] = "\r\n";
		size_t suffix_size = strlen(suffix_extra_hdrs);

		size_t  extra_header_len = prefix_size + range_size + suffix_size;
		c->extra_header = (char*) malloc( sizeof(char) * extra_header_len);



		// Copy the prefix
   	    strncpy(c->extra_header, prefix_extra_hdrs, prefix_size);

   	    // Copy the range value
   	    strncpy(c->extra_header + prefix_size, fcurrent + uri_len + 1, range_size);

   	    // Copy the suffix
   	    strncpy(c->extra_header + prefix_size + range_size, suffix_extra_hdrs, suffix_size);

   	    call_set_uri (c, uri, uri_len);
   	 	fcurrent += input_len + 1;

   	 	call_append_request_header (c, c->extra_header,extra_header_len);



    }
  while (input_len == 0);

  if (verbose)
    printf ("%s: accessing URI `%s'\n", prog_name, uri);
}
Ejemplo n.º 6
0
	static void
issue_calls (Sess *sess, Sess_Private_Data *priv)
{
	int i, to_create, retval, n;
	const char *method_str;
	Call *call;
	REQ *req;

	/* Mimic browser behavior of fetching html object, then a couple of
	   embedded objects: */

	to_create = 1;

	if (priv->num_calls_in_this_burst > 0)
	{
		to_create = priv->current_burst->num_reqs - priv->num_calls_in_this_burst;
	}

	n = session_max_qlen (sess) - session_current_qlen (sess);
	if (n < to_create)
	{
		to_create = n;
	}

	priv->num_calls_in_this_burst += to_create; 

	for (i = 0; i < to_create; ++i)
	{
		call = call_new ();
		if (!call)
		{
			sess_failure (sess);
			return;
		}

		/* fill in the new call: */
		req = priv->current_req;
		if (req == NULL)
		{
			panic ("%s: internal error, requests ran past end of burst\n",prog_name);
		}

		call_set_version (call, priv->http_version);
		method_str = call_method_name[req->method];
		call_set_method (call, method_str, strlen (method_str));
		call_set_uri (call, req->uri, req->uri_len);

#ifdef UW_DYNOUT
		call->timelimit = req->timelimit;
#endif /* UW_DYNOUT */

		/* used for call stats */
		call->file_size = req->file_size;

		if (req->cookie_len > 0)
		{
			/* add "Cookie:" header if necessary: */
			call_append_request_header (call, req->cookie, req->cookie_len);
		}
#ifdef WSESSLOG_HEADERS
		if (req->contents_len > 0 || req->extra_hdrs_len > 0)
		{
			/* add "Content-length:" header and contents, if necessary: */
			call_append_request_header (call, req->extra_hdrs,
					req->extra_hdrs_len);
			if (req->contents_len > 0)
			{
				call_set_contents(call, req->contents, req->contents_len);
			}
		}
#else
		if (req->extra_hdrs_len > 0)
		{
			/* add "Content-length:" header and contents, if necessary: */
			call_append_request_header (call, req->extra_hdrs,
					req->extra_hdrs_len);
			call_set_contents (call, req->contents, req->contents_len);
		}
#endif /* WSESSLOG_HEADERS */

#ifdef UW_CALL_STATS
		if (param.client.id >= 0)
		{
			sprintf (call->id_hdr, "Client-Id: %d %d\r\n", param.client.id, (int) call->id);

			call_append_request_header (call, call->id_hdr, strlen(call->id_hdr));
		}
#endif /* UW_CALL_STATS */

		priv->current_req = req->next;

		if (DBG > 0)
		{
			fprintf (stderr, "%s: accessing URI `%s'\n", prog_name, req->uri);
		}

		retval = session_issue_call (sess, call);
		call_dec_ref (call);

		if (retval < 0)
		{
			return;
		}
	}
}