summaryrefslogtreecommitdiff
path: root/sapi/tux/php_tux.c
diff options
context:
space:
mode:
Diffstat (limited to 'sapi/tux/php_tux.c')
-rw-r--r--sapi/tux/php_tux.c62
1 files changed, 31 insertions, 31 deletions
diff --git a/sapi/tux/php_tux.c b/sapi/tux/php_tux.c
index 8af7da40fa..bf60e04106 100644
--- a/sapi/tux/php_tux.c
+++ b/sapi/tux/php_tux.c
@@ -54,15 +54,15 @@ static int sapi_tux_ub_write(const char *str, uint str_length)
int n;
int m;
const char *estr;
-
+
/* combine headers and body */
if (TG(number_vec)) {
struct iovec *vec = TG(header_vec);
-
+
n = TG(number_vec);
vec[n].iov_base = (void *) str;
vec[n++].iov_len = str_length;
-
+
/* XXX: this might need more complete error handling */
if ((m = writev(TG(req)->sock, vec, n)) == -1 && errno == EPIPE)
php_handle_aborted_connection();
@@ -75,7 +75,7 @@ static int sapi_tux_ub_write(const char *str, uint str_length)
}
estr = str + str_length;
-
+
while (str < estr) {
n = send(TG(req)->sock, str, estr - str, 0);
@@ -83,14 +83,14 @@ static int sapi_tux_ub_write(const char *str, uint str_length)
php_handle_aborted_connection();
if (n == -1 && errno == EAGAIN)
continue;
- if (n <= 0)
+ if (n <= 0)
return n;
str += n;
}
n = str_length - (estr - str);
-
+
TG(req)->bytes_sent += n;
return n;
@@ -107,34 +107,34 @@ static int sapi_tux_send_headers(sapi_headers_struct *sapi_headers)
size_t len;
char *status_line;
int locate_cl;
-
+
max_headers = 30;
n = 1;
-
+
vec = malloc(sizeof(struct iovec) * max_headers);
status_line = malloc(30);
-
+
/* safe sprintf use */
len = slprintf(status_line, 30, "HTTP/1.1 %d NA\r\n", SG(sapi_headers).http_response_code);
-
+
vec[0].iov_base = status_line;
vec[0].iov_len = len;
-
+
TG(req)->http_status = SG(sapi_headers).http_response_code;
if (TG(tux_action) == TUX_ACTION_FINISH_CLOSE_REQ && TG(req)->http_version == HTTP_1_1)
locate_cl = 1;
else
locate_cl = 0;
-
+
h = zend_llist_get_first_ex(&sapi_headers->headers, &pos);
while (h) {
- if (locate_cl
+ if (locate_cl
&& strncasecmp(h->header, "Content-length:", sizeof("Content-length:")-1) == 0) {
TG(tux_action) = TUX_ACTION_FINISH_REQ;
locate_cl = 0;
}
-
+
vec[n].iov_base = h->header;
vec[n++].iov_len = h->header_len;
if (n >= max_headers - 3) {
@@ -143,7 +143,7 @@ static int sapi_tux_send_headers(sapi_headers_struct *sapi_headers)
}
vec[n].iov_base = "\r\n";
vec[n++].iov_len = 2;
-
+
h = zend_llist_get_next_ex(&sapi_headers->headers, &pos);
}
@@ -153,7 +153,7 @@ static int sapi_tux_send_headers(sapi_headers_struct *sapi_headers)
TG(number_vec) = n;
TG(header_vec) = vec;
-
+
return SAPI_HEADER_SENT_SUCCESSFULLY;
}
@@ -168,7 +168,7 @@ static int sapi_tux_read_post(char *buffer, uint count_bytes)
return 0;
TG(read_post_data) = 1;
-
+
return TG(req)->objectlen;
#else
return 0;
@@ -189,11 +189,11 @@ static void sapi_tux_register_variables(zval *track_vars_array)
char buf[BUF_SIZE + 1];
char *p;
sapi_header_line ctr = {0};
-
+
ctr.line = buf;
ctr.line_len = slprintf(buf, sizeof(buf), "Server: %s", TUXAPI_version);
sapi_header_op(SAPI_HEADER_REPLACE, &ctr);
-
+
php_register_variable("PHP_SELF", SG(request_info).request_uri, track_vars_array);
php_register_variable("SERVER_SOFTWARE", TUXAPI_version, track_vars_array);
php_register_variable("GATEWAY_INTERFACE", "CGI/1.1", track_vars_array);
@@ -261,10 +261,10 @@ static int php_tux_startup(sapi_module_struct *sapi_module)
static sapi_module_struct tux_sapi_module = {
"tux",
"tux",
-
+
php_tux_startup,
php_module_shutdown_wrapper,
-
+
NULL, /* activate */
NULL, /* deactivate */
@@ -274,7 +274,7 @@ static sapi_module_struct tux_sapi_module = {
NULL, /* getenv */
php_error,
-
+
NULL,
sapi_tux_send_headers,
NULL,
@@ -301,7 +301,7 @@ static void tux_module_main(void)
if (php_request_startup() == FAILURE) {
return;
}
-
+
php_execute_script(&file_handle);
php_request_shutdown(NULL);
}
@@ -315,7 +315,7 @@ static void tux_request_ctor(void)
smart_str s = {0};
char *p;
- TG(number_vec) = 0;
+ TG(number_vec) = 0;
TG(header_vec) = NULL;
SG(request_info).query_string = strdup(TG(req)->query);
@@ -326,7 +326,7 @@ static void tux_request_ctor(void)
if (p)
*p = '\0';
SG(request_info).path_translated = s.c;
-
+
s.c = NULL;
smart_str_appendc_ex(&s, '/', 1);
smart_str_appends_ex(&s, TG(req)->objectname, 1);
@@ -362,14 +362,14 @@ static void *separate_thread(void *bla)
{
int fd;
int i = 0;
-
+
fd = (int) bla;
while (i++ < 5) {
send(fd, "test<br />\n", 9, 0);
sleep(1);
}
-
+
tux(TUX_ACTION_CONTINUE_REQ, (user_req_t *) fd);
/* We HAVE to trigger some event on the fd. Otherwise
fast_thread won't wake up, so that the eventloop
@@ -386,10 +386,10 @@ int TUXAPI_handle_events(user_req_t *req)
tux_closed_conn(req->sock);
return tux(TUX_ACTION_FINISH_CLOSE_REQ, req);
}
-
+
TG(req) = req;
TG(tux_action) = TUX_ACTION_FINISH_CLOSE_REQ;
-
+
tux_request_ctor();
tux_module_main();
@@ -399,7 +399,7 @@ int TUXAPI_handle_events(user_req_t *req)
return tux(TG(tux_action), req);
}
-void tux_register_on_close(void (*arg)(int))
+void tux_register_on_close(void (*arg)(int))
{
TG(on_close) = arg;
}
@@ -412,7 +412,7 @@ void tux_closed_conn(int fd)
int tux_get_fd(void)
{
-
+
return TG(req)->sock;
}