Overview
Comment: | Fix recursive locking. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
5bd604a8f893370103a82485f89549bc |
User & Date: | js on 2009-06-01 01:31:31 |
Other Links: | manifest | tags |
Context
2009-06-01
| ||
01:44 |
It's far more likely the lock we search is at the end. Additionally, add tests for objc_sync_*. check-in: 4b03ccfe1f user: js tags: trunk | |
01:31 | Fix recursive locking. check-in: 5bd604a8f8 user: js tags: trunk | |
01:15 | Add --all to objfw-config.in. check-in: c63017b1f3 user: js tags: trunk | |
Changes
Modified src/objc_sync.m from [9f958f8552] to [469f559547].
︙ | ︙ | |||
9 10 11 12 13 14 15 16 17 18 19 20 21 22 | * the packaging of this file. */ #include "config.h" #include <stddef.h> #include <stdlib.h> #ifndef _WIN32 #include <pthread.h> #endif #import <objc/objc.h> | > | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | * the packaging of this file. */ #include "config.h" #include <stddef.h> #include <stdlib.h> #include <assert.h> #ifndef _WIN32 #include <pthread.h> #endif #import <objc/objc.h> |
︙ | ︙ | |||
138 139 140 141 142 143 144 | if (!mutex_lock(&mutex)) return 1; for (i = 0; i < num_locks; i++) { if (locks[i].obj == obj) { if (thread_is_current(locks[i].thread)) locks[i].recursion++; | | > > > > > > > > > > > > > | > | 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | if (!mutex_lock(&mutex)) return 1; for (i = 0; i < num_locks; i++) { if (locks[i].obj == obj) { if (thread_is_current(locks[i].thread)) locks[i].recursion++; else { /* Make sure objc_sync_exit doesn't free it */ locks[i].count++; /* Unlock so objc_sync_exit can return */ if (!mutex_unlock(&mutex)) return 1; if (!mutex_lock(&locks[i].mutex)) { mutex_unlock(&mutex); return 1; } if (!mutex_lock(&mutex)) return 1; assert(locks[i].recursion == 0); /* Update lock's active thread */ locks[i].thread = thread_current(); } if (!mutex_unlock(&mutex)) return 1; return 0; } } |
︙ | ︙ | |||
224 225 226 227 228 229 230 | mutex_unlock(&mutex); return 1; } locks[i].count--; if (locks[i].count == 0) { | | > > > | | > | 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 | mutex_unlock(&mutex); return 1; } locks[i].count--; if (locks[i].count == 0) { struct locks_s *new_locks = NULL; if (!mutex_free(&locks[i].mutex)) { mutex_unlock(&mutex); return 1; } num_locks--; locks[i] = locks[num_locks]; if (num_locks == 0) { free(locks); new_locks = NULL; } else if ((new_locks = realloc(locks, num_locks * sizeof(struct locks_s))) == NULL) { mutex_unlock(&mutex); return 1; } locks = new_locks; } |
︙ | ︙ |