Navigation Menu

Skip to content

Commit

Permalink
Convert raise() to pthread_kill().
Browse files Browse the repository at this point in the history
  • Loading branch information
skeeto committed Feb 1, 2017
1 parent 29bd759 commit eb8e2bd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
20 changes: 10 additions & 10 deletions elfuse-fuse.c
Expand Up @@ -54,7 +54,7 @@ elfuse_create(const char *path, mode_t mode, struct fuse_file_info *fi)

/* Wait for the funcall results */
fprintf(stderr, "CREATE request (path=%s).\n", path);
raise(SIGUSR1);
pthread_kill(emacs_thread, SIGUSR1);
sem_wait(&request_sem);

/* Got the results, see if everything's fine */
Expand Down Expand Up @@ -96,7 +96,7 @@ elfuse_rename(const char *oldpath, const char *newpath)

/* Wait for the funcall results */
fprintf(stderr, "RENAME request (oldpath=%s, newpath=%s).\n", oldpath, newpath);
raise(SIGUSR1);
pthread_kill(emacs_thread, SIGUSR1);
sem_wait(&request_sem);

if (elfuse_call.response_state == RESPONSE_SUCCESS) {
Expand Down Expand Up @@ -137,7 +137,7 @@ elfuse_getattr(const char *path, struct stat *stbuf)

/* Wait for the funcall results */
fprintf(stderr, "GETATTR request (path=%s)\n", path);
raise(SIGUSR1);
pthread_kill(emacs_thread, SIGUSR1);
sem_wait(&request_sem);

/* Got the results, see if everything's fine */
Expand Down Expand Up @@ -192,7 +192,7 @@ elfuse_readdir(const char *path, void *buf, fuse_fill_dir_t filler,

/* Wait for results */
fprintf(stderr, "READDIR request (path=%s)\n", path);
raise(SIGUSR1);
pthread_kill(emacs_thread, SIGUSR1);
sem_wait(&request_sem);

/* Got the results, see if everything's fine */
Expand Down Expand Up @@ -239,7 +239,7 @@ elfuse_open(const char *path, struct fuse_file_info *fi)

/* Wait for results */
fprintf(stderr, "OPEN request (path=%s)\n", path);
raise(SIGUSR1);
pthread_kill(emacs_thread, SIGUSR1);
sem_wait(&request_sem);

if (elfuse_call.response_state == RESPONSE_SUCCESS) {
Expand Down Expand Up @@ -284,7 +284,7 @@ elfuse_release(const char *path, struct fuse_file_info *fi)

/* Wait for results */
fprintf(stderr, "RELEASE request (path=%s)\n", path);
raise(SIGUSR1);
pthread_kill(emacs_thread, SIGUSR1);
sem_wait(&request_sem);

if (elfuse_call.response_state == RESPONSE_SUCCESS) {
Expand Down Expand Up @@ -330,7 +330,7 @@ elfuse_read(const char *path, char *buf, size_t size, off_t offset,

/* Wait for the funcall results */
fprintf(stderr, "READ request (path=%s, size=%ld, offset=%ld).\n", path, size, offset);
raise(SIGUSR1);
pthread_kill(emacs_thread, SIGUSR1);
sem_wait(&request_sem);

if (elfuse_call.response_state == RESPONSE_SUCCESS) {
Expand Down Expand Up @@ -379,7 +379,7 @@ elfuse_write(const char *path, const char *buf, size_t size, off_t offset,

/* Wait for the funcall results */
fprintf(stderr, "WRITE request (path=%s, size=%ld, offset=%ld).\n", path, size, offset);
raise(SIGUSR1);
pthread_kill(emacs_thread, SIGUSR1);
sem_wait(&request_sem);

if (elfuse_call.response_state == RESPONSE_SUCCESS) {
Expand Down Expand Up @@ -420,7 +420,7 @@ elfuse_truncate(const char *path, off_t size)

/* Wait for the funcall results */
fprintf(stderr, "TRUNCATE request (path=%s, size=%ld).\n", path, size);
raise(SIGUSR1);
pthread_kill(emacs_thread, SIGUSR1);
sem_wait(&request_sem);

if (elfuse_call.response_state == RESPONSE_SUCCESS) {
Expand Down Expand Up @@ -460,7 +460,7 @@ elfuse_unlink(const char *path)

/* Wait for the funcall results */
fprintf(stderr, "UNLINK request (path=%s).\n", path);
raise(SIGUSR1);
pthread_kill(emacs_thread, SIGUSR1);
sem_wait(&request_sem);

if (elfuse_call.response_state == RESPONSE_SUCCESS) {
Expand Down
1 change: 1 addition & 0 deletions elfuse-fuse.h
Expand Up @@ -21,6 +21,7 @@

extern sem_t request_sem;
extern sem_t init_sem;
extern pthread_t emacs_thread;

/* Init codes */
enum elfuse_init_code_enum {
Expand Down
2 changes: 2 additions & 0 deletions elfuse-module.c
Expand Up @@ -29,6 +29,7 @@ int plugin_is_GPL_compatible;

sem_t request_sem;
sem_t init_sem;
pthread_t emacs_thread;

static bool elfuse_is_started = false;
static pthread_t fuse_thread;
Expand Down Expand Up @@ -676,6 +677,7 @@ emacs_module_init (struct emacs_runtime *ert)
nil = env->intern(env, "nil");
t = env->intern(env, "t");
elfuse_op_error = env->intern(env, "elfuse-op-error");
emacs_thread = pthread_self();

emacs_value fun = env->make_function (
env, 1, 1,
Expand Down

0 comments on commit eb8e2bd

Please sign in to comment.