Page MenuHomeFreeBSD

D38345.id116227.diff
No OneTemporary

D38345.id116227.diff

diff --git a/lib/libthr/thread/thr_pshared.c b/lib/libthr/thread/thr_pshared.c
--- a/lib/libthr/thread/thr_pshared.c
+++ b/lib/libthr/thread/thr_pshared.c
@@ -213,6 +213,17 @@
_umtx_op(NULL, UMTX_OP_SHM, UMTX_SHM_DESTROY, key, NULL);
}
+static void
+pshared_destroy(struct pthread *curthread, void *key)
+{
+ void *val;
+
+ pshared_wlock(curthread);
+ val = pshared_remove(key);
+ pshared_unlock(curthread);
+ pshared_clean(key, val);
+}
+
void *
__thr_pshared_offpage(void *key, int doalloc)
{
@@ -221,11 +232,16 @@
int fd, ins_done;
curthread = _get_curthread();
- pshared_rlock(curthread);
- res = pshared_lookup(key);
- pshared_unlock(curthread);
- if (res != NULL)
- return (res);
+ if (doalloc) {
+ pshared_destroy(curthread, key);
+ res = NULL;
+ } else {
+ pshared_rlock(curthread);
+ res = pshared_lookup(key);
+ pshared_unlock(curthread);
+ if (res != NULL)
+ return (res);
+ }
fd = _umtx_op(NULL, UMTX_OP_SHM, doalloc ? UMTX_SHM_CREAT :
UMTX_SHM_LOOKUP, key, NULL);
if (fd == -1)
@@ -248,13 +264,9 @@
__thr_pshared_destroy(void *key)
{
struct pthread *curthread;
- void *val;
curthread = _get_curthread();
- pshared_wlock(curthread);
- val = pshared_remove(key);
- pshared_unlock(curthread);
- pshared_clean(key, val);
+ pshared_destroy(curthread, key);
pshared_gc(curthread);
}

File Metadata

Mime Type
text/plain
Expires
Fri, Jan 30, 3:39 AM (3 h, 2 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28093772
Default Alt Text
D38345.id116227.diff (1 KB)

Event Timeline