summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustus Winter <4winter@informatik.uni-hamburg.de>2015-09-28 15:23:31 +0200
committerJustus Winter <4winter@informatik.uni-hamburg.de>2015-09-28 15:23:31 +0200
commit54eca4d85fadbed49b59f504ffcede624c487e92 (patch)
treec0077ee1aa8159acf64897c4a5c22c1804c82de8
parentfcaaa9cb56f94e99d50d9680d6caf67d75b518c8 (diff)
eth-filter: convert to trivfs dynamic classes and buckets
libtrivfs contains two ways of managing more than one port class and bucket. There is the old way of using a statically allocated array with explicit length, and the new way with dynamically allocated vectors. Converting all users to the new way of handling multiple classes and/or buckets, we can simplify the code in libtrivfs. In many cases, the code will be simpler and more expressive for the user. This also fixes a mild bug. The classes and buckets given to `trivfs_startup' end up in the dynamic vectors too, making the object lookup code use the more complicated code path. * eth-filter/filter.c: Convert to dynamic classes and buckets.
-rw-r--r--eth-filter/filter.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/eth-filter/filter.c b/eth-filter/filter.c
index 482b0800..58fcd65d 100644
--- a/eth-filter/filter.c
+++ b/eth-filter/filter.c
@@ -125,11 +125,6 @@ int trivfs_support_write = 0;
int trivfs_support_exec = 0;
int trivfs_allow_open = O_READ | O_WRITE;
-struct port_class *trivfs_protid_portclasses[1];
-struct port_class *trivfs_cntl_portclasses[1];
-int trivfs_protid_nportclasses = 1;
-int trivfs_cntl_nportclasses = 1;
-
/* For getting the notification of ports from the kernel. */
struct port_info *notify_pi;
@@ -194,6 +189,10 @@ clean_proxy_device (void *p)
device->proxy->device = NULL;
}
+/* Our port classes. */
+struct port_class *trivfs_protid_class;
+struct port_class *trivfs_cntl_class;
+
int
ethernet_demuxer (mach_msg_header_t *inp,
mach_msg_header_t *outp)
@@ -206,7 +205,8 @@ ethernet_demuxer (mach_msg_header_t *inp,
if (inp->msgh_id != NET_RCV_MSG_ID)
return 0;
- device = ports_lookup_port (port_bucket, inp->msgh_local_port, device_portclass);
+ device = ports_lookup_port (port_bucket, inp->msgh_local_port,
+ device_portclass);
if (device == NULL)
return 0;
proxy = device->proxy;
@@ -582,8 +582,8 @@ trivfs_goaway (struct trivfs_control *fsys, int flags)
int count;
/* Stop new requests. */
- ports_inhibit_class_rpcs (trivfs_cntl_portclasses[0]);
- ports_inhibit_class_rpcs (trivfs_protid_portclasses[0]);
+ ports_inhibit_class_rpcs (trivfs_cntl_class);
+ ports_inhibit_class_rpcs (trivfs_protid_class);
count = ports_count_class (user_portclass);
debug ("the number of ports alive: %d\n", count);
@@ -591,9 +591,9 @@ trivfs_goaway (struct trivfs_control *fsys, int flags)
if (count && !(flags & FSYS_GOAWAY_FORCE))
{
/* We won't go away, so start things going again... */
- ports_enable_class (trivfs_protid_portclasses[0]);
- ports_resume_class_rpcs (trivfs_cntl_portclasses[0]);
- ports_resume_class_rpcs (trivfs_protid_portclasses[0]);
+ ports_enable_class (trivfs_protid_class);
+ ports_resume_class_rpcs (trivfs_cntl_class);
+ ports_resume_class_rpcs (trivfs_protid_class);
return EBUSY;
}
@@ -778,8 +778,8 @@ main (int argc, char *argv[])
user_portclass = ports_create_class (clean_proxy_user, 0);
device_portclass = ports_create_class (clean_proxy_device, 0);
other_portclass = ports_create_class (0, 0);
- trivfs_cntl_portclasses[0] = ports_create_class (trivfs_clean_cntl, 0);
- trivfs_protid_portclasses[0] = ports_create_class (trivfs_clean_protid, 0);
+ trivfs_cntl_class = ports_create_class (trivfs_clean_cntl, 0);
+ trivfs_protid_class = ports_create_class (trivfs_clean_protid, 0);
argp_parse (&argp, argc, argv, 0, 0, 0);
@@ -806,8 +806,8 @@ main (int argc, char *argv[])
/* Reply to our parent. */
err = trivfs_startup (bootstrap, 0,
- trivfs_cntl_portclasses[0], port_bucket,
- trivfs_protid_portclasses[0], port_bucket, &fsys);
+ trivfs_cntl_class, port_bucket,
+ trivfs_protid_class, port_bucket, &fsys);
mach_port_deallocate (mach_task_self (), bootstrap);
if (err)
error (1, err, "Contacting parent");