Initialize svr4_head during MOD_LOAD rather than on demand.
This commit is contained in:
parent
93a73e5a00
commit
a02f5c6204
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=160504
@ -75,17 +75,6 @@ svr4_find_socket(td, fp, dev, ino)
|
||||
struct svr4_sockcache_entry *e;
|
||||
void *cookie = ((struct socket *)fp->f_data)->so_emuldata;
|
||||
|
||||
if (svr4_str_initialized != 2) {
|
||||
if (atomic_cmpset_acq_int(&svr4_str_initialized, 0, 1)) {
|
||||
DPRINTF(("svr4_find_socket: uninitialized [%p,%d,%d]\n",
|
||||
td, dev, ino));
|
||||
TAILQ_INIT(&svr4_head);
|
||||
atomic_store_rel_int(&svr4_str_initialized, 2);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
DPRINTF(("svr4_find_socket: [%p,%d,%d]: ", td, dev, ino));
|
||||
TAILQ_FOREACH(e, &svr4_head, entries)
|
||||
if (e->p == td->td_proc && e->dev == dev && e->ino == ino) {
|
||||
@ -118,19 +107,6 @@ svr4_add_socket(td, path, st)
|
||||
|
||||
mtx_lock(&Giant);
|
||||
|
||||
/*
|
||||
* Wait for the TAILQ to be initialized. Only the very first CPU
|
||||
* will succeed on the atomic_cmpset(). The other CPU's will spin
|
||||
* until the first one finishes the initialization. Once the
|
||||
* initialization is complete, the condition will always fail
|
||||
* avoiding expensive atomic operations in the common case.
|
||||
*/
|
||||
while (svr4_str_initialized != 2)
|
||||
if (atomic_cmpset_acq_int(&svr4_str_initialized, 0, 1)) {
|
||||
TAILQ_INIT(&svr4_head);
|
||||
atomic_store_rel_int(&svr4_str_initialized, 2);
|
||||
}
|
||||
|
||||
e = malloc(sizeof(*e), M_TEMP, M_WAITOK);
|
||||
e->cookie = NULL;
|
||||
e->dev = st->st_dev;
|
||||
|
@ -70,9 +70,6 @@ static d_open_t streamsopen;
|
||||
|
||||
struct svr4_sockcache_head svr4_head;
|
||||
|
||||
/* Initialization flag (set/queried by svr4_mod LKM) */
|
||||
int svr4_str_initialized = 0;
|
||||
|
||||
/*
|
||||
* Device minor numbers
|
||||
*/
|
||||
@ -122,7 +119,7 @@ streams_modevent(module_t mod, int type, void *unused)
|
||||
{
|
||||
switch (type) {
|
||||
case MOD_LOAD:
|
||||
/* XXX should make sure it isn't already loaded first */
|
||||
TAILQ_INIT(&svr4_head);
|
||||
dt_ptm = make_dev(&streams_cdevsw, dev_ptm, 0, 0, 0666,
|
||||
"ptm");
|
||||
dt_arp = make_dev(&streams_cdevsw, dev_arp, 0, 0, 0666,
|
||||
@ -382,14 +379,6 @@ svr4_delete_socket(p, fp)
|
||||
struct svr4_sockcache_entry *e;
|
||||
void *cookie = ((struct socket *)fp->f_data)->so_emuldata;
|
||||
|
||||
while (svr4_str_initialized != 2) {
|
||||
if (atomic_cmpset_acq_int(&svr4_str_initialized, 0, 1)) {
|
||||
TAILQ_INIT(&svr4_head);
|
||||
atomic_store_rel_int(&svr4_str_initialized, 2);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
TAILQ_FOREACH(e, &svr4_head, entries)
|
||||
if (e->p == p && e->cookie == cookie) {
|
||||
TAILQ_REMOVE(&svr4_head, e, entries);
|
||||
|
Loading…
Reference in New Issue
Block a user