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
This commit is contained in:
parent
c71cfbac7a
commit
2a5dcba5ed
File diff suppressed because it is too large
Load Diff
@ -27,7 +27,7 @@
|
||||
|
||||
#define BASE64_LENGTH(len) (4 * (((len) + 2) / 3))
|
||||
|
||||
static char *base64Dup(char *s)
|
||||
static char *base64dup(char *s)
|
||||
{
|
||||
int i;
|
||||
int len = strlen(s);
|
||||
@ -64,7 +64,7 @@ static char *base64Dup(char *s)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static char *authString(const char *header,
|
||||
static char *auth_string(const char *header,
|
||||
const char *user, const char *password)
|
||||
{
|
||||
char *ret = NULL;
|
||||
@ -80,7 +80,7 @@ static char *authString(const char *header,
|
||||
strcpy(temp, user);
|
||||
strcat(temp, ":");
|
||||
strcat(temp, password);
|
||||
temp64 = base64Dup(temp);
|
||||
temp64 = base64dup(temp);
|
||||
free(temp);
|
||||
|
||||
ret = xmalloc(strlen(temp64) + strlen(header) + 3);
|
||||
@ -95,7 +95,7 @@ static char *authString(const char *header,
|
||||
#define PROXY_AUTH_HEADER "Proxy-Authorization: Basic "
|
||||
#define HTTP_AUTH_HEADER "Authorization: Basic "
|
||||
|
||||
#define proxyAuthString(x, y) authString(PROXY_AUTH_HEADER, x, y)
|
||||
#define httpAuthString(x, y) authString(HTTP_AUTH_HEADER, x, y)
|
||||
#define proxy_auth_string(x, y) auth_string(PROXY_AUTH_HEADER, x, y)
|
||||
#define http_auth_string(x, y) auth_string(HTTP_AUTH_HEADER, x, y)
|
||||
|
||||
#endif /* INPUT_STREAM_HTTP_AUTH_H */
|
||||
|
Loading…
Reference in New Issue
Block a user