mirror of
https://github.com/rkd77/elinks.git
synced 2024-10-01 03:36:26 -04:00
Revert "IPC: added the prefix 'my' to the semaphore functions."
This reverts commit e6e8b3407d
.
This commit is contained in:
parent
2d69e2e625
commit
cdcbdd720d
@ -65,7 +65,7 @@ struct program program;
|
|||||||
int epoll_fd;
|
int epoll_fd;
|
||||||
int master_sem = -1;
|
int master_sem = -1;
|
||||||
int shared_mem_ipc = -1;
|
int shared_mem_ipc = -1;
|
||||||
char *shared_mem = NULL;
|
unsigned char *shared_mem = NULL;
|
||||||
|
|
||||||
static int ac;
|
static int ac;
|
||||||
static unsigned char **av;
|
static unsigned char **av;
|
||||||
@ -124,14 +124,12 @@ init_master_ipc(void)
|
|||||||
return;
|
return;
|
||||||
k1 = ftok(filename.source, 1);
|
k1 = ftok(filename.source, 1);
|
||||||
k2 = ftok(filename.source, 2);
|
k2 = ftok(filename.source, 2);
|
||||||
master_sem = mysem_create(k1, 0);
|
master_sem = sem_create(k1, 0);
|
||||||
shared_mem_ipc = shmget(k2, 4096, 0600 | IPC_CREAT | IPC_EXCL);
|
shared_mem_ipc = shmget(k2, 4096, 0600 | IPC_CREAT | IPC_EXCL);
|
||||||
if (shared_mem_ipc == -1 && errno == EEXIST)
|
if (shared_mem_ipc == -1 && errno == EEXIST)
|
||||||
shared_mem_ipc = shmget(k2, 4096, 0600);
|
shared_mem_ipc = shmget(k2, 4096, 0600);
|
||||||
if (shared_mem_ipc >= 0) {
|
if (shared_mem_ipc >= 0) {
|
||||||
shared_mem = shmat(shared_mem_ipc, NULL, 0);
|
shared_mem = shmat(shared_mem_ipc, NULL, 0);
|
||||||
if (shared_mem == (char *)-1)
|
|
||||||
shared_mem = NULL;
|
|
||||||
}
|
}
|
||||||
done_string(&filename);
|
done_string(&filename);
|
||||||
#endif
|
#endif
|
||||||
@ -148,12 +146,10 @@ init_slave_ipc(void)
|
|||||||
return;
|
return;
|
||||||
k1 = ftok(filename.source, 1);
|
k1 = ftok(filename.source, 1);
|
||||||
k2 = ftok(filename.source, 2);
|
k2 = ftok(filename.source, 2);
|
||||||
master_sem = mysem_open(k1);
|
master_sem = sem_open(k1);
|
||||||
shared_mem_ipc = shmget(k2, 4096, 0600);
|
shared_mem_ipc = shmget(k2, 4096, 0600);
|
||||||
if (shared_mem_ipc >= 0) {
|
if (shared_mem_ipc >= 0) {
|
||||||
shared_mem = shmat(shared_mem_ipc, NULL, 0);
|
shared_mem = shmat(shared_mem_ipc, NULL, 0);
|
||||||
if (shared_mem == (char *)-1)
|
|
||||||
shared_mem = NULL;
|
|
||||||
}
|
}
|
||||||
done_string(&filename);
|
done_string(&filename);
|
||||||
#endif
|
#endif
|
||||||
@ -166,7 +162,7 @@ done_ipc(void)
|
|||||||
if (shared_mem)
|
if (shared_mem)
|
||||||
shmdt(shared_mem);
|
shmdt(shared_mem);
|
||||||
if (master_sem >= 0)
|
if (master_sem >= 0)
|
||||||
mysem_close(master_sem);
|
sem_close(master_sem);
|
||||||
/* shared_mem_ipc will be automatically done by sem_close() */
|
/* shared_mem_ipc will be automatically done by sem_close() */
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@
|
|||||||
#include "util/string.h"
|
#include "util/string.h"
|
||||||
|
|
||||||
extern int master_sem;
|
extern int master_sem;
|
||||||
extern char *shared_mem;
|
extern unsigned char *shared_mem;
|
||||||
|
|
||||||
struct mailcap_hash_item {
|
struct mailcap_hash_item {
|
||||||
/* The entries associated with the type */
|
/* The entries associated with the type */
|
||||||
@ -694,7 +694,7 @@ get_mime_handler_mailcap(unsigned char *type, struct terminal *term)
|
|||||||
hard_write(term->fdout, data, len + 2);
|
hard_write(term->fdout, data, len + 2);
|
||||||
fmem_free(data);
|
fmem_free(data);
|
||||||
|
|
||||||
mysem_wait(master_sem);
|
sem_wait(master_sem);
|
||||||
if (!*shared_mem)
|
if (!*shared_mem)
|
||||||
return NULL;
|
return NULL;
|
||||||
desc = strchr(shared_mem, '\0') + 1;
|
desc = strchr(shared_mem, '\0') + 1;
|
||||||
@ -753,7 +753,7 @@ get_slave_mailcap(unsigned char *type)
|
|||||||
}
|
}
|
||||||
end:
|
end:
|
||||||
done_mailcap(NULL);
|
done_mailcap(NULL);
|
||||||
mysem_signal(master_sem);
|
sem_signal(master_sem);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ static struct sembuf op_op[1] = {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
int
|
int
|
||||||
mysem_create(key_t key, int initval /* used if we create the semaphore */)
|
sem_create(key_t key, int initval /* used if we create the semaphore */)
|
||||||
{
|
{
|
||||||
int id, semval;
|
int id, semval;
|
||||||
union semun {
|
union semun {
|
||||||
@ -191,7 +191,7 @@ again:
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
int
|
int
|
||||||
mysem_open(key_t key)
|
sem_open(key_t key)
|
||||||
{
|
{
|
||||||
int id;
|
int id;
|
||||||
|
|
||||||
@ -224,7 +224,7 @@ mysem_open(key_t key)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
mysem_rm(int id)
|
sem_rm(int id)
|
||||||
{
|
{
|
||||||
semctl(id, 0, IPC_RMID, 0);
|
semctl(id, 0, IPC_RMID, 0);
|
||||||
/* err_sys("can't IPC_RMID"); */
|
/* err_sys("can't IPC_RMID"); */
|
||||||
@ -244,7 +244,7 @@ mysem_rm(int id)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
mysem_close(int id)
|
sem_close(int id)
|
||||||
{
|
{
|
||||||
int semval;
|
int semval;
|
||||||
|
|
||||||
@ -271,7 +271,7 @@ mysem_close(int id)
|
|||||||
/* if (semval > BIGCOUNT)
|
/* if (semval > BIGCOUNT)
|
||||||
err_dump("sem[1] > BIGCOUNT"); */
|
err_dump("sem[1] > BIGCOUNT"); */
|
||||||
if (semval == BIGCOUNT)
|
if (semval == BIGCOUNT)
|
||||||
mysem_rm(id);
|
sem_rm(id);
|
||||||
else
|
else
|
||||||
semop(id, &op_unlock[0], 1);
|
semop(id, &op_unlock[0], 1);
|
||||||
/* err_sys("can't unlock"); */ /* unlock */
|
/* err_sys("can't unlock"); */ /* unlock */
|
||||||
@ -284,9 +284,9 @@ mysem_close(int id)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
mysem_wait(int id)
|
sem_wait(int id)
|
||||||
{
|
{
|
||||||
mysem_op(id, -1);
|
sem_op(id, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -294,9 +294,9 @@ mysem_wait(int id)
|
|||||||
* Dijkstra's V operation. Tanenbaum's UP operation.
|
* Dijkstra's V operation. Tanenbaum's UP operation.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
mysem_signal(int id)
|
sem_signal(int id)
|
||||||
{
|
{
|
||||||
mysem_op(id, 1);
|
sem_op(id, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -304,7 +304,7 @@ mysem_signal(int id)
|
|||||||
* amount (positive or negative; amount can't be zero).
|
* amount (positive or negative; amount can't be zero).
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
mysem_op(int id, int value)
|
sem_op(int id, int value)
|
||||||
{
|
{
|
||||||
op_op[0].sem_op = value;
|
op_op[0].sem_op = value;
|
||||||
/* err_sys("can't have value == 0"); */
|
/* err_sys("can't have value == 0"); */
|
||||||
|
@ -6,12 +6,12 @@
|
|||||||
#include <sys/sem.h>
|
#include <sys/sem.h>
|
||||||
#include <sys/shm.h>
|
#include <sys/shm.h>
|
||||||
|
|
||||||
int mysem_create(key_t key, int initval);
|
int sem_create(key_t key, int initval);
|
||||||
int mysem_open(key_t key);
|
int sem_open(key_t key);
|
||||||
void mysem_rm(int id);
|
void sem_rm(int id);
|
||||||
void mysem_close(int id);
|
void sem_close(int id);
|
||||||
void mysem_wait(int id);
|
void sem_wait(int id);
|
||||||
void mysem_signal(int id);
|
void sem_signal(int id);
|
||||||
void mysem_op(int id, int value);
|
void sem_op(int id, int value);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user