Project

General

Profile

Revision 880dc54f

ID880dc54fdbb40937890923ffda9180a8b72d7357
Parent 75cef49f
Child 15928a3d

Added by Thomas Mullins about 11 years ago

Fixed curl SSL queries failing and queue bug

View differences:

mainbox/event.c
18 18
  else
19 19
    head = event;
20 20
  tail = event;
21
  event->next = NULL;
21 22
}
22 23

  
23 24
void event_q_process() {
mainbox/event.h
11 11
  struct event_t *next;
12 12
};
13 13

  
14
/*
15
 * After event_alloc, you must call either event_free or event_q_push.
16
 * Periodically call event_q_process to send events in the queue to the server.
17
 * When an event is successfully sent, the event will be removed from the queue
18
 * and freed.
19
 */
14 20
struct event_t *event_alloc();
15 21
void event_free(struct event_t *event);
16 22
void event_q_push(struct event_t *event);
mainbox/query.c
10 10

  
11 11
  server = server_name;
12 12

  
13
  error_code = curl_global_init(CURL_GLOBAL_NOTHING);
13
  error_code = curl_global_init(CURL_GLOBAL_SSL);
14 14
  if (error_code)
15 15
    fprintf(stderr, "curl_global_init: %s\n", curl_easy_strerror(error_code));
16 16

  
......
33 33
  return nmemb;
34 34
}
35 35

  
36
static size_t write_ignore(void *buffer, size_t size, size_t nmemb,
37
    void *userp) {
38
  return nmemb;
39
}
40

  
36 41
/*
37 42
 * query_user_permission
38 43
 *
......
139 144
  error_code = curl_easy_setopt(handle, CURLOPT_URL, buf);
140 145
  if (error_code) goto error;
141 146

  
147
  error_code = curl_easy_setopt(handle, CURLOPT_SSL_VERIFYHOST, 0L);
148
  if (error_code) goto error;
149

  
150
  error_code = curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, write_ignore);
151
  if (error_code) goto error;
152

  
142 153
  error_code = curl_easy_setopt(handle, CURLOPT_HTTPPOST, formpost);
143 154
  if (error_code) goto error;
144 155

  
......
153 164
    fprintf(stderr, "Warning: response %ld from %s\n", response, buf);
154 165

  
155 166
  curl_easy_cleanup(handle);
167
  curl_formfree(formpost);
156 168
  return response >= 300;
157 169

  
158 170
error:
159 171
  fprintf(stderr, "curl: %s\n", curl_easy_strerror(error_code));
160 172
  curl_easy_cleanup(handle);
173
  curl_formfree(formpost);
161 174
  return 1;
162 175
}

Also available in: Unified diff