mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
IPC: Check headers.
This commit is contained in:
parent
f45d4c1782
commit
4a3559e0b2
@ -201,6 +201,7 @@ AC_CHECK_HEADERS(sys/utsname.h)
|
||||
AC_CHECK_HEADERS(stdint.h inttypes.h)
|
||||
AC_CHECK_HEADERS(locale.h pwd.h)
|
||||
AC_CHECK_HEADERS(termios.h)
|
||||
AC_CHECK_HEADERS(sys/ipc.h sys/sem.h sys/shm.h)
|
||||
|
||||
AC_CHECK_HEADERS(sys/epoll.h, [HAVE_SYS_EPOLL_H=yes])
|
||||
|
||||
|
@ -54,7 +54,9 @@
|
||||
#include "util/file.h"
|
||||
#include "util/memdebug.h"
|
||||
#include "util/memory.h"
|
||||
#if defined(HAVE_SYS_IPC_H) && defined(HAVE_SYS_SEM_H) && defined(HAVE_SYS_SHM_H)
|
||||
#include "util/sem.h"
|
||||
#endif
|
||||
#include "viewer/dump/dump.h"
|
||||
#include "viewer/text/festival.h"
|
||||
#include "viewer/text/marks.h"
|
||||
@ -115,6 +117,7 @@ check_cwd(void)
|
||||
static void
|
||||
init_master_ipc(void)
|
||||
{
|
||||
#if defined(HAVE_SYS_IPC_H) && defined(HAVE_SYS_SEM_H) && defined(HAVE_SYS_SHM_H)
|
||||
struct string filename;
|
||||
key_t k1, k2, k3;
|
||||
|
||||
@ -132,11 +135,13 @@ init_master_ipc(void)
|
||||
shared_mem = shmat(shared_mem_ipc, NULL, 0);
|
||||
}
|
||||
done_string(&filename);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
init_slave_ipc(void)
|
||||
{
|
||||
#if defined(HAVE_SYS_IPC_H) && defined(HAVE_SYS_SEM_H) && defined(HAVE_SYS_SHM_H)
|
||||
struct string filename;
|
||||
key_t k1, k2, k3;
|
||||
|
||||
@ -152,11 +157,13 @@ init_slave_ipc(void)
|
||||
shared_mem = shmat(shared_mem_ipc, NULL, 0);
|
||||
}
|
||||
done_string(&filename);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
done_ipc(void)
|
||||
{
|
||||
#if defined(HAVE_SYS_IPC_H) && defined(HAVE_SYS_SEM_H) && defined(HAVE_SYS_SHM_H)
|
||||
if (shared_mem)
|
||||
shmdt(shared_mem);
|
||||
if (master_sem >= 0)
|
||||
@ -164,6 +171,7 @@ done_ipc(void)
|
||||
if (slave_sem >= 0)
|
||||
sem_close(slave_sem);
|
||||
/* shared_mem_ipc will be automatically done by sem_close() */
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -41,7 +41,9 @@
|
||||
#include "util/hash.h"
|
||||
#include "util/lists.h"
|
||||
#include "util/memory.h"
|
||||
#if defined(HAVE_SYS_IPC_H) && defined(HAVE_SYS_SEM_H) && defined(HAVE_SYS_SHM_H)
|
||||
#include "util/sem.h"
|
||||
#endif
|
||||
#include "util/string.h"
|
||||
|
||||
extern int master_sem;
|
||||
@ -671,11 +673,11 @@ get_mime_handler_mailcap_common(unsigned char *type)
|
||||
static struct mime_handler *
|
||||
get_mime_handler_mailcap(unsigned char *type, struct terminal *term)
|
||||
{
|
||||
struct mime_handler *handler;
|
||||
struct mime_handler *handler = NULL;
|
||||
unsigned char *desc, *data;
|
||||
int block, len;
|
||||
|
||||
if (!term || term->master)
|
||||
if (!term || term->master || slave_sem == -1)
|
||||
return get_mime_handler_mailcap_common(type);
|
||||
|
||||
len = strlen(type) + 1;
|
||||
@ -687,16 +689,20 @@ get_mime_handler_mailcap(unsigned char *type, struct terminal *term)
|
||||
memcpy(data + 2, type, len);
|
||||
hard_write(term->fdout, data, len + 2);
|
||||
fmem_free(data);
|
||||
|
||||
#if defined(HAVE_SYS_IPC_H) && defined(HAVE_SYS_SEM_H) && defined(HAVE_SYS_SHM_H)
|
||||
if (!shared_mem)
|
||||
return NULL;
|
||||
shared_mem[0] = '\0'; /* For unexpected death of slave. */
|
||||
sem_signal(slave_sem);
|
||||
sem_wait(master_sem);
|
||||
if (!shared_mem || !*shared_mem)
|
||||
if (!*shared_mem)
|
||||
return NULL;
|
||||
desc = strchr(shared_mem, '\0') + 1;
|
||||
block = (shared_mem[4095] > 0);
|
||||
handler = init_mime_handler(shared_mem, desc, mailcap_mime_module.name,
|
||||
get_mailcap_ask(), block);
|
||||
if (handler) handler->copiousoutput = shared_mem[4095] & 1;
|
||||
#endif
|
||||
return handler;
|
||||
}
|
||||
|
||||
@ -704,6 +710,7 @@ get_mime_handler_mailcap(unsigned char *type, struct terminal *term)
|
||||
void
|
||||
get_slave_mailcap(unsigned char *type)
|
||||
{
|
||||
#if defined(HAVE_SYS_IPC_H) && defined(HAVE_SYS_SEM_H) && defined(HAVE_SYS_SHM_H)
|
||||
sem_wait(slave_sem);
|
||||
if (shared_mem) {
|
||||
struct mailcap_entry *entry;
|
||||
@ -748,6 +755,7 @@ get_slave_mailcap(unsigned char *type)
|
||||
}
|
||||
end:
|
||||
sem_signal(master_sem);
|
||||
#endif
|
||||
}
|
||||
|
||||
const struct mime_backend mailcap_mime_backend = {
|
||||
|
@ -563,7 +563,9 @@ has_nul_byte:
|
||||
|
||||
if (fg == 3) {
|
||||
/* Mailcap */
|
||||
#ifdef CONFIG_MAILCAP
|
||||
get_slave_mailcap(path.source);
|
||||
#endif
|
||||
goto next_round;
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@ or use of these programs.
|
||||
|
||||
#include "elinks.h"
|
||||
|
||||
#if defined(HAVE_SYS_IPC_H) && defined(HAVE_SYS_SEM_H) && defined(HAVE_SYS_SHM_H)
|
||||
#include "util/sem.h"
|
||||
|
||||
extern int shared_mem_ipc;
|
||||
@ -311,3 +312,4 @@ sem_op(int id, int value)
|
||||
semop(id, &op_op[0], 1);
|
||||
/* err_sys("sem_op error"); */
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user