summaryrefslogtreecommitdiff
path: root/src/trg-client.h
diff options
context:
space:
mode:
authorGravatar Alan Fitton <ajf@eth0.org.uk>2011-09-11 10:27:06 +0000
committerGravatar Alan Fitton <ajf@eth0.org.uk>2011-09-11 10:27:06 +0000
commitbe569c0953fcd777ae00ae41feb9c673e4df2f23 (patch)
treede0c822ae4ca82e5a717a04a11271f6d544c6507 /src/trg-client.h
parent547bcd3c5ec89e30f20723b46c8eab1a71e0cf44 (diff)
use thread local storage to keep one curl client per thread (by default 3) in the thread pool
Diffstat (limited to 'src/trg-client.h')
-rw-r--r--src/trg-client.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/trg-client.h b/src/trg-client.h
index 67d026b..78a674d 100644
--- a/src/trg-client.h
+++ b/src/trg-client.h
@@ -16,12 +16,14 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+
/* trg-client.h */
#ifndef _TRG_CLIENT_H_
#define _TRG_CLIENT_H_
#define TRANSMISSION_MIN_SUPPORTED 2.0
+#define X_TRANSMISSION_SESSION_ID_HEADER_PREFIX "X-Transmission-Session-Id: "
#define TRG_MAX_RETRIES 3
#define TORRENT_GET_MODE_FIRST 0
@@ -32,12 +34,24 @@
#define TRG_NO_HOSTNAME_SET -2
#define SESSION_UPDATE_DIVISOR 10
+#include <curl/curl.h>
+#include <curl/easy.h>
+
#include <json-glib/json-glib.h>
#include <glib-object.h>
#include "trg-prefs.h"
#include "session-get.h"
+#define HTTP_OK 200
+#define HTTP_CONFLICT 409
+
+typedef struct {
+ int status;
+ char *data;
+ int size;
+} trg_http_response;
+
G_BEGIN_DECLS
#define TRG_TYPE_CLIENT trg_client_get_type()
@@ -67,6 +81,25 @@ typedef struct {
} TrgClientClass;
+/* Thread local storage (TLS).
+ * CURL clients can't be used concurrently.
+ * So create one instance for each thread in the thread pool.
+ */
+typedef struct {
+ /* Use a serial to figure out when there's been a configuration change
+ * by comparing with priv->serial.
+ * We lock updating (and checking for updates) with priv->configMutex
+ */
+ int serial;
+ CURL *curl;
+ trg_http_response *response;
+} trg_tls;
+
+/* stuff that used to be in http.h */
+void http_response_free(trg_http_response *response);
+trg_http_response *trg_http_perform(TrgClient * client, gchar * req);
+/* end http.h*/
+
GType trg_client_get_type (void);
TrgClient* trg_client_new (void);