Project

General

Profile

Actions

Bug #5968

open

libilb'ilb_close() misses mutex_unlock in some places

Added by Serghei Samsi almost 7 years ago.

Status:
New
Priority:
Normal
Assignee:
Category:
lib - userland libraries
Start date:
2015-05-29
Due date:
% Done:

0%

Estimated time:
Difficulty:
Medium
Tags:
needs-triage
Gerrit CR:

Description

/illumos-gate/usr/src/lib/libilb/common/ilb_comm.c:
Lines 131,146 should unlock mutex hi->hi_lock.

118ilb_status_t
119ilb_close(ilb_handle_t h)
120{
121 ilb_handle_impl_t *hi = (ilb_handle_impl_t *)h;
122
123 if (h == ILB_INVALID_HANDLE)
124 return (ILB_STATUS_EINVAL);
125
126 if (mutex_lock(&hi->h_lock) != 0)
127 return (ILB_STATUS_INTERNAL);
128
129 /* Somebody has done a close, no need to do anything. */
130 if (hi->h_closing) {
131 return (ILB_STATUS_OK);
132 } else {
133 hi->h_closing = B_TRUE;
134 hi->h_error = ILB_STATUS_HANDLE_CLOSING;
135 }
136
137 /* Wait until there is nobody waiting. */
138 while (hi->h_waiter > 0) {
139 if (cond_wait(&hi->h_cv, &hi->h_lock) != 0) {
140 (void) mutex_unlock(&hi->h_lock);
141 return (ILB_STATUS_INTERNAL);
142 }
143 }
144 /* No one is waiting, proceed to free the handle. */
145
146 (void) close(hi->h_socket);
147 (void) mutex_destroy(&hi->h_lock);
148 (void) cond_destroy(&hi->h_cv);
149 free(hi);
150 return (ILB_STATUS_OK);
151}

No data to display

Actions

Also available in: Atom PDF