[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
mouse.diff ( X loses mouse on trivial operation)
From: |
David Walter |
Subject: |
mouse.diff ( X loses mouse on trivial operation) |
Date: |
Mon, 28 Oct 2002 14:55:12 -0500 |
User-agent: |
Gnus/5.090007 (Oort Gnus v0.07) XEmacs/21.4 (Honest Recruiter, hurd-i386-debian) |
X loses mouse on trivial operation
ls -l /dev/mouse
The mouse translator formerly believed it needed to start a new thread
for every open call. It also _closed_ the device after every
corresponding close_hook call.
The device reader thread moved to before main (no prototype added).
2002-10-28 David Walter <dwalter@syr.edu>
* mouse.c (main): moved thread create from open_hook (one thread
per open) to main, one device master thread per process.
* mouse.c (trivfs_goaway): moved device_close from close_hook to
here.
* mouse.c : removed close_hook
* mouse.c (trivfs_modify_stat): conditionalized modify stat for
first open.
diff --unified --ignore-case --ignore-all-space
/ryojusen/opt/src/hurd-20021011/trans/mouse.c /opt/hurd/trans/mouse.c
--- /ryojusen/opt/src/hurd-20021011/trans/mouse.c 2002-10-28
14:32:39.000000000 -0500
+++ /opt/hurd/trans/mouse.c 2002-10-28 14:34:46.000000000 -0500
@@ -128,36 +128,6 @@
return 0;
}
-int
-main (int argc, char **argv)
-{
- error_t err;
- mach_port_t bootstrap;
- struct trivfs_control *fsys;
-
- const struct argp argp = { options, parse_opt };
-
- if (argp_parse (&argp, argc, argv, 0, 0, 0))
- error (1, 0, "argp_parse failed.");
-
- set_mouse_device_name ();
-
- task_get_bootstrap_port (mach_task_self (), &bootstrap);
- if (bootstrap == MACH_PORT_NULL)
- error (1, 0, "Must be started as a translator");
-
- /* Reply to our parent */
- err = trivfs_startup (bootstrap, 0, 0, 0, 0, 0, &fsys);
- if (err)
- error (3, err, "Contacting parent");
- /* Launch. */
- mutex_init (&mouse.lock);
- ports_manage_port_operations_multithread (fsys->pi.bucket, trivfs_demuxer,
- 2 * 60 * 1000, 0, 0);
-
- exit (0);
-}
-
static any_t
mouse_thread (any_t arg)
{
@@ -189,6 +159,38 @@
}
}
+int
+main (int argc, char **argv)
+{
+ error_t err;
+ mach_port_t bootstrap;
+ struct trivfs_control *fsys;
+
+ const struct argp argp = { options, parse_opt };
+
+ if (argp_parse (&argp, argc, argv, 0, 0, 0))
+ error (1, 0, "argp_parse failed.");
+
+ set_mouse_device_name ();
+
+ task_get_bootstrap_port (mach_task_self (), &bootstrap);
+ if (bootstrap == MACH_PORT_NULL)
+ error (1, 0, "Must be started as a translator");
+
+ /* Reply to our parent */
+ err = trivfs_startup (bootstrap, 0, 0, 0, 0, 0, &fsys);
+ if (err)
+ error (3, err, "Contacting parent");
+ /* Launch. */
+ mutex_init (&mouse.lock);
+ mouse.cnt = 0;
+ cthread_detach (cthread_fork (mouse_thread, 0));
+ ports_manage_port_operations_multithread (fsys->pi.bucket, trivfs_demuxer,
+ 2 * 60 * 1000, 0, 0);
+
+ exit (0);
+}
+
static error_t
open_hook (struct trivfs_peropen *po)
{
@@ -205,23 +207,13 @@
err = device_open (master, D_READ, mouse_device_name, &mouse.port);
mach_port_deallocate (mach_task_self (), master);
}
- mouse.cnt = 0;
- cthread_detach (cthread_fork (mouse_thread, 0));
mutex_unlock (&mouse.lock);
return err;
}
-static void
-close_hook (struct trivfs_peropen *po)
-{
- device_close (mouse.port);
- mouse.port = (mach_port_t) NULL;
-}
-
/* Trivfs hooks */
error_t (*trivfs_peropen_create_hook) (struct trivfs_peropen *) = open_hook;
-void (*trivfs_peropen_destroy_hook) (struct trivfs_peropen *) = close_hook;
int trivfs_fstype = FSTYPE_DEV;
int trivfs_fsid = 0;
@@ -235,6 +227,9 @@
void
trivfs_modify_stat (struct trivfs_protid *cred, struct stat *st)
{
+ static int initialized = FALSE;
+ if (!initialized)
+ {
st->st_blksize = vm_page_size * 256; /* Make transfers LARRRRRGE */
st->st_size = 0;
@@ -242,11 +237,15 @@
st->st_mode &= ~S_IFMT;
st->st_mode |= S_IFCHR;
+ initialized = TRUE;
+ }
}
error_t
trivfs_goaway (struct trivfs_control *fsys, int flags)
{
+ device_close (mouse.port);
+ mouse.port = (mach_port_t) NULL;
exit (0);
}
--
/^\
\ / ASCII RIBBON CAMPAIGN
X AGAINST HTML MAIL
/ \
Public Key Server (pgp.dtype.org) -- Index 'dwalter@syr.edu'
Type bits /keyID Date User ID
pub 1024D/DC92AE30 2002/02/26 David Walter <dwalter@syr.edu>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- mouse.diff ( X loses mouse on trivial operation),
David Walter <=