Threaded fixes
FossilOrigin-Name: d81c32b38b46db09fc33f45708d91c99bad5a31655567ad859e35c332c881476
This commit is contained in:
parent
115acd3231
commit
bf8785674f
5 changed files with 41 additions and 3 deletions
|
@ -16,6 +16,7 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "helpers.h"
|
||||
|
@ -30,8 +31,10 @@
|
|||
#include "cgi.h"
|
||||
#include "global_cache.h"
|
||||
|
||||
|
||||
#define BODY_STYLE "style=\"background:url('%s');\""
|
||||
|
||||
|
||||
void render_base_page(struct base_page* page, FCGX_Request* req, struct session* ssn, mstdnt_t* api)
|
||||
{
|
||||
struct mstdnt_args m_args;
|
||||
|
@ -94,10 +97,12 @@ void render_base_page(struct base_page* page, FCGX_Request* req, struct session*
|
|||
|
||||
void send_result(FCGX_Request* req, char* status, char* content_type, char* data, size_t data_len)
|
||||
{
|
||||
static pthread_mutex_t print_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
if (data_len == 0) data_len = strlen(data);
|
||||
#ifdef SINGLE_THREADED
|
||||
printf(
|
||||
#else
|
||||
pthread_mutex_lock(&print_mutex);
|
||||
FCGX_FPrintF(req->out,
|
||||
#endif
|
||||
"Status: %s\r\n"
|
||||
|
@ -110,5 +115,6 @@ void send_result(FCGX_Request* req, char* status, char* content_type, char* data
|
|||
puts(data);
|
||||
#else
|
||||
FCGX_PutStr(data, data_len, req->out);
|
||||
pthread_mutex_unlock(&print_mutex);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -26,6 +26,9 @@
|
|||
#include "l10n.h"
|
||||
#include "local_config.h"
|
||||
#include "path.h"
|
||||
#include <pthread.h>
|
||||
|
||||
|
||||
enum base_category
|
||||
{
|
||||
BASE_CAT_NONE,
|
||||
|
|
|
@ -185,8 +185,9 @@ void content_login(PATH_ARGS)
|
|||
}
|
||||
else {
|
||||
if (url_link)
|
||||
{
|
||||
PRINTF("Set-Cookie: instance_url=%s; Path=/; Max-Age=31536000\r\n", url_link);
|
||||
else
|
||||
} else
|
||||
// Clear
|
||||
PUT("Set-Cookie: instance_url=; Path=/; Max-Age=-1\r\n");
|
||||
|
||||
|
|
21
src/request.c
Normal file
21
src/request.c
Normal file
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* Treebird - Lightweight frontend for Pleroma
|
||||
* Copyright (C) 2022 Nekobit
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "request.h"
|
||||
|
||||
pthread_mutex_t print_mutex = PTHREAD_MUTEX_INITIALIZER;
|
|
@ -18,14 +18,21 @@
|
|||
|
||||
#ifndef REQUEST_H
|
||||
#define REQUEST_H
|
||||
#include <pthread.h>
|
||||
|
||||
extern pthread_mutex_t print_mutex;
|
||||
|
||||
#ifdef SINGLE_THREADED
|
||||
#define PRINTF(str, ...) printf(str, __VA_ARGS__)
|
||||
#define PUT(str) printf(str)
|
||||
#define REQUEST_T void*
|
||||
#else
|
||||
#define PRINTF(str, ...) FCGX_FPrintF(req->out, str, __VA_ARGS__)
|
||||
#define PUT(str) FCGX_FPrintF(req->out, str)
|
||||
#define PRINTF(str, ...) do { pthread_mutex_lock(&print_mutex); \
|
||||
FCGX_FPrintF(req->out, str, __VA_ARGS__); \
|
||||
pthread_mutex_unlock(&print_mutex); } while (1);
|
||||
#define PUT(str) do { pthread_mutex_lock(&print_mutex); \
|
||||
FCGX_FPrintF(req->out, str); \
|
||||
pthread_mutex_unlock(&print_mutex); } while (1);
|
||||
#define REQUEST_T FCGX_Request*
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in a new issue