-fixing misc minor bugs and compiler warnings in libmicrospdy

This commit is contained in:
Christian Grothoff committed 2013-06-27 14:41:35 +00:00
1 parent 79f2eea262
commit fe8202d39c
8 files changed
+108 -62

No files matched your search

+23 -13
View File
@@ -41,15 +41,17 @@
//#include "../framinglayer/structures.h"
//#include "../applicationlayer/alstructures.h"
int run = 1;
int run2 = 1;
static int run = 1;
static int run2 = 1;
uint64_t loops;
time_t start;
static uint64_t loops;
static time_t start;
void
static void
new_session_callback (void *cls,
struct SPDY_Session * session)
{
@@ -88,7 +90,8 @@ new_session_callback (void *cls,
}
}
void
static void
session_closed_handler (void *cls,
struct SPDY_Session * session,
int by_client)
@@ -108,7 +111,8 @@ session_closed_handler (void *cls,
//session_closed_called = 1;
}
void
static void
response_done_callback(void *cls,
struct SPDY_Response *response,
struct SPDY_Request *request,
@@ -135,7 +139,8 @@ response_done_callback(void *cls,
free(cls);
}
int
static int
print_headers (void *cls,
const char *name, const char *value)
{
@@ -163,11 +168,12 @@ new_request_cb (void *cls,
}
*/
int
static int
append_headers_to_data (void *cls,
const char *name, const char **value, int num_values)
const char *name, const char * const *value, int num_values)
{
char **data = (char **)cls;
char **data = cls;
void *tofree = *data;
int i;
@@ -183,7 +189,8 @@ append_headers_to_data (void *cls,
return SPDY_YES;
}
void
static void
standard_request_handler(void *cls,
struct SPDY_Request * request,
uint8_t priority,
@@ -251,11 +258,14 @@ standard_request_handler(void *cls,
}
}
void sig_handler(int signo)
static void
sig_handler(int signo)
{
printf("received signal\n");
}
int
main (int argc, char *const *argv)
{
+10 -7
View File
@@ -32,10 +32,10 @@
#include <errno.h>
#include "microspdy.h"
int run = 1;
static int run = 1;
ssize_t
static ssize_t
response_callback (void *cls,
void *buffer,
size_t max,
@@ -53,11 +53,12 @@ response_callback (void *cls,
}
void
static void
response_done_callback(void *cls,
struct SPDY_Response *response,
struct SPDY_Request *request,
bool streamopened)
struct SPDY_Response *response,
struct SPDY_Request *request,
enum SPDY_RESPONSE_RESULT status,
bool streamopened)
{
(void)streamopened;
printf("answer for %s was sent\n", (char *)cls);
@@ -67,7 +68,8 @@ response_done_callback(void *cls,
free(cls);
}
void
static void
standard_request_handler(void *cls,
struct SPDY_Request * request,
uint8_t priority,
@@ -141,6 +143,7 @@ standard_request_handler(void *cls,
}
}
int
main (int argc, char *const *argv)
{
+24
View File
@@ -51,6 +51,30 @@
#include <zlib.h>
#include <stdbool.h>
/* While we generally would like users to use a configure-driven
build process which detects which headers are present and
hence works on any platform, we use "standard" includes here
to build out-of-the-box for beginning users on common systems.
Once you have a proper build system and go for more exotic
platforms, you should define MHD_PLATFORM_H in some header that
you always include *before* "microhttpd.h". Then the following
"standard" includes won't be used (which might be a good
idea, especially on platforms where they do not exist). */
#ifndef MHD_PLATFORM_H
#include <unistd.h>
#include <stdarg.h>
#include <stdint.h>
#ifdef __MINGW32__
#include <ws2tcpip.h>
#else
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
#endif
#endif
/**
* return code for "YES".
*/
+5 -5
View File
@@ -217,11 +217,11 @@ spdy_handler_response_queue_result(void * cls,
int streamopened;
struct SPDY_Request *request = (struct SPDY_Request *)cls;
SPDYF_ASSERT(NULL == response_queue->data_frame
&& NULL != response_queue->control_frame
|| NULL != response_queue->data_frame
&& NULL == response_queue->control_frame,
"response queue must have either control frame or data frame");
SPDYF_ASSERT( ( (NULL == response_queue->data_frame) &&
(NULL != response_queue->control_frame) ) ||
( (NULL != response_queue->data_frame) &&
(NULL == response_queue->control_frame) ),
"response queue must have either control frame or data frame");
streamopened = !response_queue->stream->is_out_closed;
+9 -9
View File
@@ -423,15 +423,15 @@ SPDYF_get_fdset (struct SPDY_Daemon *daemon,
{
fd = pos->socket_fd;
FD_SET(fd, read_fd_set);
if(all
|| NULL != pos->response_queue_head //frames pending
|| NULL != pos->write_buffer //part of last frame pending
|| SPDY_SESSION_STATUS_CLOSING == pos->status //the session is about to be closed
|| daemon->session_timeout //timeout passed for the session
&& (pos->last_activity + daemon->session_timeout < SPDYF_monotonic_time())
|| SPDY_YES == SPDYF_tls_is_pending(pos) //data in TLS' read buffer pending
|| ((pos->read_buffer_offset - pos->read_buffer_beginning) > 0) // data in lib's read buffer pending
)
if (all
|| (NULL != pos->response_queue_head) //frames pending
|| (NULL != pos->write_buffer) //part of last frame pending
|| (SPDY_SESSION_STATUS_CLOSING == pos->status) //the session is about to be closed
|| (daemon->session_timeout //timeout passed for the session
&& (pos->last_activity + daemon->session_timeout < SPDYF_monotonic_time()))
|| (SPDY_YES == SPDYF_tls_is_pending(pos)) //data in TLS' read buffer pending
|| ((pos->read_buffer_offset - pos->read_buffer_beginning) > 0) // data in lib's read buffer pending
)
FD_SET(fd, write_fd_set);
if(fd > max_fd)
max_fd = fd;
+2
View File
@@ -932,6 +932,7 @@ SPDYF_session_write (struct SPDY_Session *session, bool only_one_frame)
//on respones with callbacks it is possible that their is no
//data available
if(0 == session->write_buffer_size)//nothing to write
{
if(response_queue != session->response_queue_head)
{
//the handler modified the queue
@@ -942,6 +943,7 @@ SPDYF_session_write (struct SPDY_Session *session, bool only_one_frame)
//no need to try the same frame again
break;
}
}
}
session->last_activity = SPDYF_monotonic_time();
+7 -6
View File
@@ -27,6 +27,7 @@
#include "structures.h"
#include "internal.h"
#include "session.h"
#include <ctype.h>
struct SPDY_NameValue *
@@ -60,7 +61,7 @@ SPDY_name_value_add (struct SPDY_NameValue *container,
for(i=0; i<len; ++i)
{
if(isupper(name[i]))
if(isupper((int) name[i]))
return SPDY_INPUT_ERROR;
}
@@ -289,12 +290,12 @@ SPDYF_response_queue_create(bool is_data,
unsigned int i;
bool is_last;
SPDYF_ASSERT(!is_data
|| 0 == data_size && NULL != response->rcb
|| 0 < data_size && NULL == response->rcb,
"either data or request->rcb must not be null");
SPDYF_ASSERT((! is_data)
|| ((0 == data_size) && (NULL != response->rcb))
|| ((0 < data_size) && (NULL == response->rcb)),
"either data or request->rcb must not be null");
if(is_data && data_size > SPDY_MAX_SUPPORTED_FRAME_SIZE)
if (is_data && (data_size > SPDY_MAX_SUPPORTED_FRAME_SIZE))
{
//separate the data in more frames and add them to the queue
+28 -22
View File
@@ -127,10 +127,13 @@ struct URI
while(0)
int loop = 1;
CURLM *multi_handle;
int still_running = 0; /* keep number of running handles */
regex_t uri_preg;
static int loop = 1;
static CURLM *multi_handle;
static int still_running = 0; /* keep number of running handles */
static regex_t uri_preg;
struct Proxy
@@ -151,7 +154,7 @@ struct Proxy
};
void
static void
free_uri(struct URI * uri)
{
if(NULL != uri)
@@ -170,7 +173,8 @@ free_uri(struct URI * uri)
}
}
int
static int
init_parse_uri(regex_t * preg)
{
// RFC 2396
@@ -186,14 +190,16 @@ init_parse_uri(regex_t * preg)
return regcomp(preg, "^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?", REG_EXTENDED);
}
void
static void
deinit_parse_uri(regex_t * preg)
{
regfree(preg);
}
int
parse_uri(regex_t * preg, char * full_uri, struct URI ** uri)
static int
parse_uri(regex_t * preg, const char * full_uri, struct URI ** uri)
{
int ret;
char *colon;
@@ -305,7 +311,7 @@ response_callback (void *cls,
}
void
static void
response_done_callback(void *cls,
struct SPDY_Response *response,
struct SPDY_Request *request,
@@ -490,7 +496,7 @@ curl_write_cb(void *contents, size_t size, size_t nmemb, void *userp)
}
int
static int
iterate_cb (void *cls, const char *name, const char * const * value, int num_values)
{
struct Proxy *proxy = (struct Proxy *)cls;
@@ -528,7 +534,7 @@ iterate_cb (void *cls, const char *name, const char * const * value, int num_val
}
void
static void
standard_request_handler(void *cls,
struct SPDY_Request * request,
uint8_t priority,
@@ -627,8 +633,9 @@ standard_request_handler(void *cls,
}
}
int
run()
static int
run ()
{
unsigned long long timeoutlong=0;
long curl_timeo = -1;
@@ -645,9 +652,7 @@ run()
CURLMsg *msg;
int msgs_left;
struct Proxy *proxy;
struct sockaddr_in *addr;
struct sockaddr_in addr4;
struct in_addr inaddr4;
struct sockaddr_in *addr;
struct addrinfo hints;
char service[NI_MAXSERV];
struct addrinfo *gai;
@@ -679,16 +684,16 @@ run()
}
else
{
snprintf(service, sizeof(service), "%u", glob_opt.listen_port);
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC;
snprintf (service, sizeof(service), "%u", glob_opt.listen_port);
memset (&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;
ret = getaddrinfo(glob_opt.listen_host, service, &hints, &gai);
if(ret != 0)
DIE("problem with specified host");
addr=gai->ai_addr;
addr = (struct sockaddr_in *) gai->ai_addr;
daemon = SPDY_start_daemon(0,
glob_opt.cert,
@@ -836,7 +841,8 @@ run()
return 0;
}
void
static void
display_usage()
{
printf(