ia64/xen-unstable

changeset 2619:f00a106e5d16

bitkeeper revision 1.1159.105.1 (416a80f6SZ7Hz6Hx7iorFvqBB6UMlg)

Disable libcurl's "Expect: 100-continue" header since the twisted http server
doesn't send the expected answer and libcurl will wait for ~2 seconds before
sending POST data.
author cl349@freefall.cl.cam.ac.uk
date Mon Oct 11 12:47:50 2004 +0000 (2004-10-11)
parents c3493b09c749
children 1594b2cbd611
files tools/xfrd/xen_domain.c
line diff
     1.1 --- a/tools/xfrd/xen_domain.c	Thu Oct 07 15:25:52 2004 +0000
     1.2 +++ b/tools/xfrd/xen_domain.c	Mon Oct 11 12:47:50 2004 +0000
     1.3 @@ -189,10 +189,11 @@ int curldebug(CURL *curl, curl_infotype 
     1.4   * @param fmt url format string, followed by parameters
     1.5   * @return 0 on success, error code otherwise
     1.6   */
     1.7 -static int curlsetup(CURL **pcurl, char *url, int url_n, char *fmt, ...){
     1.8 +static int curlsetup(CURL **pcurl, struct curl_slist **pheaders, char *url, int url_n, char *fmt, ...){
     1.9      int err = 0;
    1.10      va_list args;
    1.11      CURL *curl = NULL;
    1.12 +    struct curl_slist *headers = NULL;
    1.13      int n = 0;
    1.14  
    1.15      curl = curlinit();
    1.16 @@ -224,15 +225,29 @@ static int curlsetup(CURL **pcurl, char 
    1.17  #endif
    1.18      // Set the URL.
    1.19      curl_easy_setopt(curl, CURLOPT_URL, url);
    1.20 +
    1.21 +    headers = curl_slist_append(headers, "Expect:");
    1.22 +    curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
    1.23 +    
    1.24    exit:
    1.25      if(err && curl){
    1.26          curl_easy_cleanup(curl);
    1.27          curl = NULL;
    1.28      }
    1.29      *pcurl = curl;
    1.30 +    if (pheaders)
    1.31 +	*pheaders = headers;
    1.32      return err;
    1.33  }
    1.34  
    1.35 +static void curlcleanup(CURL **pcurl, struct curl_slist **pheaders){
    1.36 +    if (*pcurl)
    1.37 +	curl_easy_cleanup(*pcurl);
    1.38 +    if (*pheaders)
    1.39 +	curl_slist_free_all(*pheaders);
    1.40 +    *pcurl = NULL;
    1.41 +    *pheaders = NULL;
    1.42 +}
    1.43  /** Make the http request stored in the curl handle and get
    1.44   *  the result code from the curl code and the http return code.
    1.45   *
    1.46 @@ -268,15 +283,16 @@ int curlresult(CURL *curl){
    1.47  int xen_domain_ls(void){
    1.48      int err = 0;
    1.49      CURL *curl = NULL;
    1.50 +    struct curl_slist *headers = NULL;
    1.51      char url[128] = {};
    1.52      int url_n = sizeof(url);
    1.53  
    1.54      dprintf(">\n");
    1.55 -    err = curlsetup(&curl, url, url_n, "http://localhost:%d/xend/domain", XEND_PORT);
    1.56 +    err = curlsetup(&curl, &headers, url, url_n, "http://localhost:%d/xend/domain", XEND_PORT);
    1.57      if(err) goto exit;
    1.58      err = curlresult(curl);
    1.59    exit:
    1.60 -    if(curl) curl_easy_cleanup(curl);
    1.61 +    curlcleanup(&curl, &headers);
    1.62      dprintf("< err=%d\n", err);
    1.63      return err;
    1.64  }
    1.65 @@ -291,6 +307,7 @@ int xen_domain_ls(void){
    1.66  int xen_domain_configure(uint32_t dom, char *vmconfig, int vmconfig_n){
    1.67      int err = 0;
    1.68      CURL *curl = NULL;
    1.69 +    struct curl_slist *headers = NULL;
    1.70      char url[128] = {};
    1.71      int url_n = sizeof(url);
    1.72      struct curl_httppost *form = NULL, *last = NULL;
    1.73 @@ -300,7 +317,7 @@ int xen_domain_configure(uint32_t dom, c
    1.74      // List domains so that xend will update its domain list and notice the new domain.
    1.75      xen_domain_ls();
    1.76  
    1.77 -    err = curlsetup(&curl, url, url_n, "http://localhost:%d/xend/domain/%u", XEND_PORT, dom);
    1.78 +    err = curlsetup(&curl, &headers, url, url_n, "http://localhost:%d/xend/domain/%u", XEND_PORT, dom);
    1.79      if(err) goto exit;
    1.80  
    1.81      // Config field - set from vmconfig.
    1.82 @@ -329,7 +346,7 @@ int xen_domain_configure(uint32_t dom, c
    1.83      curl_easy_setopt(curl, CURLOPT_HTTPPOST, form);
    1.84      err = curlresult(curl);
    1.85    exit:
    1.86 -    if(curl) curl_easy_cleanup(curl);
    1.87 +    curlcleanup(&curl, &headers);
    1.88      if(form) curl_formfree(form);
    1.89      dprintf("< err=%d\n", err);
    1.90      return err;
    1.91 @@ -343,6 +360,7 @@ int xen_domain_configure(uint32_t dom, c
    1.92  int xen_domain_unpause(uint32_t dom){
    1.93      int err = 0;
    1.94      CURL *curl = NULL;
    1.95 +    struct curl_slist *headers = NULL;
    1.96      char url[128] = {};
    1.97      int url_n = sizeof(url);
    1.98      struct curl_httppost *form = NULL, *last = NULL;
    1.99 @@ -350,7 +368,7 @@ int xen_domain_unpause(uint32_t dom){
   1.100  
   1.101      dprintf("> dom=%u\n", dom);
   1.102  
   1.103 -    err = curlsetup(&curl, url, url_n, "http://localhost:%d/xend/domain/%u", XEND_PORT, dom);
   1.104 +    err = curlsetup(&curl, &headers, url, url_n, "http://localhost:%d/xend/domain/%u", XEND_PORT, dom);
   1.105      if(err) goto exit;
   1.106  
   1.107      // Op field.
   1.108 @@ -367,7 +385,7 @@ int xen_domain_unpause(uint32_t dom){
   1.109      curl_easy_setopt(curl, CURLOPT_HTTPPOST, form);
   1.110      err = curlresult(curl);
   1.111    exit:
   1.112 -    if(curl) curl_easy_cleanup(curl);
   1.113 +    curlcleanup(&curl, &headers);
   1.114      if(form) curl_formfree(form);
   1.115      dprintf("< err=%d\n", err);
   1.116      return err;