Commit 2a5dcba5 authored by Eric Wong's avatar Eric Wong

http: initial rewrite using ringbuffer + pthreads

This institutes the usage of a separate thread to buffer HTTP input. It is basically practice code for using the ringbuffer code which I plan on reusing for the OutputBuffer as well as further input buffering for disk (networked filesystems over WAN, laptops on battery, etc). Each readFromInputStream() call on an HTTP stream can take several seconds to complete, short reads are avoided. A single-threaded solution for systems supporting large enough SO_RCVBUF values should also be possible and will likely be done in the future; but this lock-free(except when full/empty) ringbuffer is cool :) git-svn-id: https://svn.musicpd.org/mpd/trunk@7393 09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent c71cfbac
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#define BASE64_LENGTH(len) (4 * (((len) + 2) / 3)) #define BASE64_LENGTH(len) (4 * (((len) + 2) / 3))
static char *base64Dup(char *s) static char *base64dup(char *s)
{ {
int i; int i;
int len = strlen(s); int len = strlen(s);
...@@ -64,8 +64,8 @@ static char *base64Dup(char *s) ...@@ -64,8 +64,8 @@ static char *base64Dup(char *s)
return ret; return ret;
} }
static char *authString(const char *header, static char *auth_string(const char *header,
const char *user, const char *password) const char *user, const char *password)
{ {
char *ret = NULL; char *ret = NULL;
int templen; int templen;
...@@ -80,7 +80,7 @@ static char *authString(const char *header, ...@@ -80,7 +80,7 @@ static char *authString(const char *header,
strcpy(temp, user); strcpy(temp, user);
strcat(temp, ":"); strcat(temp, ":");
strcat(temp, password); strcat(temp, password);
temp64 = base64Dup(temp); temp64 = base64dup(temp);
free(temp); free(temp);
ret = xmalloc(strlen(temp64) + strlen(header) + 3); ret = xmalloc(strlen(temp64) + strlen(header) + 3);
...@@ -95,7 +95,7 @@ static char *authString(const char *header, ...@@ -95,7 +95,7 @@ static char *authString(const char *header,
#define PROXY_AUTH_HEADER "Proxy-Authorization: Basic " #define PROXY_AUTH_HEADER "Proxy-Authorization: Basic "
#define HTTP_AUTH_HEADER "Authorization: Basic " #define HTTP_AUTH_HEADER "Authorization: Basic "
#define proxyAuthString(x, y) authString(PROXY_AUTH_HEADER, x, y) #define proxy_auth_string(x, y) auth_string(PROXY_AUTH_HEADER, x, y)
#define httpAuthString(x, y) authString(HTTP_AUTH_HEADER, x, y) #define http_auth_string(x, y) auth_string(HTTP_AUTH_HEADER, x, y)
#endif /* INPUT_STREAM_HTTP_AUTH_H */ #endif /* INPUT_STREAM_HTTP_AUTH_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment