Revision a7fb19e1 xseg/peers/user/mt-mapperd.c

b/xseg/peers/user/mt-mapperd.c
137 137

  
138 138

  
139 139
#define wait_on_pr(__pr, __condition__) 	\
140
	while (__condition__){			\
140
	do {					\
141 141
		ta--;				\
142 142
		__get_mapper_io(pr)->active = 0;\
143 143
		XSEGLOG2(&lc, D, "Waiting on pr %lx, ta: %u",  pr, ta); \
144 144
		st_cond_wait(__pr->cond);	\
145
	}
145
	} while (__condition__)
146 146

  
147 147
#define wait_on_mapnode(__mn, __condition__)	\
148
	while (__condition__){			\
148
	do {					\
149 149
		ta--;				\
150 150
		__mn->waiters++;		\
151 151
		XSEGLOG2(&lc, D, "Waiting on map node %lx %s, waiters: %u, \
152 152
			ta: %u",  __mn, __mn->object, __mn->waiters, ta);  \
153 153
		st_cond_wait(__mn->cond);	\
154
	}
154
	} while (__condition__)
155 155

  
156 156
#define wait_on_map(__map, __condition__)	\
157
	while (__condition__){			\
157
	do {					\
158 158
		ta--;				\
159 159
		__map->waiters++;		\
160 160
		XSEGLOG2(&lc, D, "Waiting on map %lx %s, waiters: %u, ta: %u",\
161 161
				   __map, __map->volume, __map->waiters, ta); \
162 162
		st_cond_wait(__map->cond);	\
163
	}
163
	} while (__condition__)
164 164

  
165 165
#define signal_pr(__pr)				\
166 166
	do { 					\
......
1635 1635
			if (mn) {
1636 1636
				//make sure all pending operations on all objects are completed
1637 1637
				//this should never happen...
1638
				wait_on_mapnode(mn, mn->flags & MF_OBJECT_NOT_READY);
1638
				if (mn->flags & MF_OBJECT_NOT_READY)
1639
					wait_on_mapnode(mn, mn->flags & MF_OBJECT_NOT_READY);
1639 1640
				mn->flags |= MF_OBJECT_DESTROYED;
1640 1641
				put_mapnode(mn); //matchin mn->ref = 1 on mn init
1641 1642
				put_mapnode(mn); //matcing get_mapnode;
......
2033 2034
				if (mn->flags & MF_OBJECT_NOT_READY){
2034 2035
					if (!can_wait)
2035 2036
						continue;
2036
					wait_on_mapnode(mn, mn->flags & MF_OBJECT_NOT_READY);
2037
					if (mn->flags & MF_OBJECT_NOT_READY)
2038
						wait_on_mapnode(mn, mn->flags & MF_OBJECT_NOT_READY);
2037 2039
					if (mn->flags & MF_OBJECT_DESTROYED){
2038 2040
						mio->err = 1;
2039 2041
						continue;
......
2057 2059
			}
2058 2060
			can_wait = 1;
2059 2061
		}
2060
		wait_on_pr(pr, mio->copyups > 0);
2062
		if (mio->copyups > 0)
2063
			wait_on_pr(pr, mio->copyups > 0);
2061 2064
	}
2062 2065

  
2063 2066
	if (mio->err){
......
2108 2111
		if (mn) {
2109 2112
			if (!(mn->flags & MF_OBJECT_DESTROYED)){
2110 2113
				//make sure all pending operations on all objects are completed
2111
				wait_on_mapnode(mn, mn->flags & MF_OBJECT_NOT_READY);
2114
				if (mn->flags & MF_OBJECT_NOT_READY)
2115
					wait_on_mapnode(mn, mn->flags & MF_OBJECT_NOT_READY);
2112 2116
				mn->flags |= MF_OBJECT_DESTROYED;
2113 2117
			}
2114 2118
			put_mapnode(mn);
......
2176 2180
		 * this should be nr_ops of the blocker, but since we don't know
2177 2181
		 * that, we assume based on our own nr_ops
2178 2182
		 */
2179
		wait_on_pr(pr, mio->snap_pending >= peer->nr_ops);
2183
		if (mio->snap_pending >= peer->nr_ops)
2184
			wait_on_pr(pr, mio->snap_pending >= peer->nr_ops);
2180 2185

  
2181 2186
		mn = get_mapnode(map, i);
2182 2187
		if (!mn)
......
2187 2192
			continue;
2188 2193
		}
2189 2194
		// make sure all pending operations on all objects are completed
2190
		wait_on_mapnode(mn, mn->flags & MF_OBJECT_NOT_READY);
2195
		if (mn->flags & MF_OBJECT_NOT_READY)
2196
			wait_on_mapnode(mn, mn->flags & MF_OBJECT_NOT_READY);
2191 2197

  
2192 2198
		/* TODO will this ever happen?? */
2193 2199
		if (mn->flags & MF_OBJECT_DESTROYED){
......
2205 2211
		/* do not put_mapnode here. cb does that */
2206 2212
	}
2207 2213

  
2208
	wait_on_pr(pr, mio->snap_pending > 0);
2214
	if (mio->snap_pending > 0)
2215
		wait_on_pr(pr, mio->snap_pending > 0);
2209 2216
	mio->cb = NULL;
2210 2217

  
2211 2218
	if (mio->err)
......
2303 2310
		 * this should be nr_ops of the blocker, but since we don't know
2304 2311
		 * that, we assume based on our own nr_ops
2305 2312
		 */
2306
		wait_on_pr(pr, mio->del_pending >= peer->nr_ops);
2313
		if (mio->del_pending >= peer->nr_ops)
2314
			wait_on_pr(pr, mio->del_pending >= peer->nr_ops);
2307 2315

  
2308 2316
		mn = get_mapnode(map, i);
2309 2317
		if (!mn)
......
2319 2327
		}
2320 2328

  
2321 2329
		// make sure all pending operations on all objects are completed
2322
		wait_on_mapnode(mn, mn->flags & MF_OBJECT_NOT_READY);
2330
		if (mn->flags & MF_OBJECT_NOT_READY)
2331
			wait_on_mapnode(mn, mn->flags & MF_OBJECT_NOT_READY);
2323 2332

  
2324 2333
		req = __delete_object(pr, mn);
2325 2334
		if (!req){
......
2331 2340
		/* do not put_mapnode here. cb does that */
2332 2341
	}
2333 2342

  
2334
	wait_on_pr(pr, mio->del_pending > 0);
2343
	if (mio->del_pending > 0)
2344
		wait_on_pr(pr, mio->del_pending > 0);
2335 2345

  
2336 2346
	mio->cb = NULL;
2337 2347
	map->flags &= ~MF_MAP_DELETING;

Also available in: Unified diff