diff options
author | Mike Buland <eichlan@xagasoft.com> | 2009-04-16 23:04:35 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2009-04-16 23:04:35 +0000 |
commit | 44057a75ef001bfd1919e2169ec3f7f355d14c20 (patch) | |
tree | 61cc7fe3ea5d54a24197a33bd7ec87edc5d8233b /src | |
parent | 900bf84c403caf83e18928b066544f402aae1122 (diff) | |
download | libbu++-44057a75ef001bfd1919e2169ec3f7f355d14c20.tar.gz libbu++-44057a75ef001bfd1919e2169ec3f7f355d14c20.tar.bz2 libbu++-44057a75ef001bfd1919e2169ec3f7f355d14c20.tar.xz libbu++-44057a75ef001bfd1919e2169ec3f7f355d14c20.zip |
Hey, the list code is better, also, I fixed some stuff in socket (the
isBlocking function was backward), and fastcgi is actually working now!
Also added comparison functions to FString.
Diffstat (limited to 'src')
-rw-r--r-- | src/fastcgi.cpp | 123 | ||||
-rw-r--r-- | src/fastcgi.h | 4 | ||||
-rw-r--r-- | src/fbasicstring.h | 32 | ||||
-rw-r--r-- | src/list.h | 90 | ||||
-rw-r--r-- | src/socket.cpp | 4 |
5 files changed, 206 insertions, 47 deletions
diff --git a/src/fastcgi.cpp b/src/fastcgi.cpp index aba3b71..9a602de 100644 --- a/src/fastcgi.cpp +++ b/src/fastcgi.cpp | |||
@@ -50,13 +50,17 @@ bool Bu::FastCgi::isEmbedded() | |||
50 | 50 | ||
51 | void Bu::FastCgi::read( Bu::Socket &s, Bu::FastCgi::Record &r ) | 51 | void Bu::FastCgi::read( Bu::Socket &s, Bu::FastCgi::Record &r ) |
52 | { | 52 | { |
53 | s.read( &r, sizeof(Record) ); | 53 | int iRead = s.read( &r, sizeof(Record) ); |
54 | if( iRead != sizeof(Record) ) | ||
55 | throw Bu::SocketException("Hey, the size %d is wrong for Record. (%s)", | ||
56 | iRead, strerror( errno ) ); | ||
54 | r.uRequestId = ntohs( r.uRequestId ); | 57 | r.uRequestId = ntohs( r.uRequestId ); |
55 | r.uContentLength = ntohs( r.uContentLength ); | 58 | r.uContentLength = ntohs( r.uContentLength ); |
56 | } | 59 | } |
57 | 60 | ||
58 | void Bu::FastCgi::write( Bu::Socket &s, Bu::FastCgi::Record r ) | 61 | void Bu::FastCgi::write( Bu::Socket &s, Bu::FastCgi::Record r ) |
59 | { | 62 | { |
63 | sio << "Out -> " << r << sio.nl; | ||
60 | r.uRequestId = htons( r.uRequestId ); | 64 | r.uRequestId = htons( r.uRequestId ); |
61 | r.uContentLength = htons( r.uContentLength ); | 65 | r.uContentLength = htons( r.uContentLength ); |
62 | s.write( &r, sizeof(Record) ); | 66 | s.write( &r, sizeof(Record) ); |
@@ -111,8 +115,30 @@ void Bu::FastCgi::readPair( Bu::Socket &s, StrHash &hParams, uint16_t &uRead ) | |||
111 | } | 115 | } |
112 | } | 116 | } |
113 | 117 | ||
118 | bool Bu::FastCgi::hasChannel( int iChan ) | ||
119 | { | ||
120 | if( aChannel.getSize() < iChan ) | ||
121 | return false; | ||
122 | if( aChannel[iChan-1] == NULL ) | ||
123 | return false; | ||
124 | return true; | ||
125 | } | ||
126 | |||
127 | Bu::Formatter &Bu::operator<<( Bu::Formatter &f, const Bu::FastCgi::Record &r ) | ||
128 | { | ||
129 | f << "[Ver=" << (uint32_t)r.uVersion << | ||
130 | ", Type=" << (uint32_t)r.uType << | ||
131 | ", Req=" << (uint32_t)r.uRequestId << | ||
132 | ", clen=" << (uint32_t)r.uContentLength << | ||
133 | ", plen=" << (uint32_t)r.uPaddingLength << | ||
134 | ", resv=" << (uint32_t)r.uReserved << | ||
135 | "]"; | ||
136 | return f; | ||
137 | } | ||
138 | |||
114 | void Bu::FastCgi::run() | 139 | void Bu::FastCgi::run() |
115 | { | 140 | { |
141 | sio << "sizeof(Bu::FastCgi::Record) = " << sizeof(Record) << sio.nl; | ||
116 | bRunning = true; | 142 | bRunning = true; |
117 | while( bRunning ) | 143 | while( bRunning ) |
118 | { | 144 | { |
@@ -122,21 +148,49 @@ void Bu::FastCgi::run() | |||
122 | 148 | ||
123 | Bu::Socket s( iSock ); | 149 | Bu::Socket s( iSock ); |
124 | s.setBlocking( true ); | 150 | s.setBlocking( true ); |
151 | sio << "Got connection, blocking? " << s.isBlocking() << sio.nl; | ||
125 | try | 152 | try |
126 | { | 153 | { |
127 | for(;;) | 154 | for(;;) |
128 | { | 155 | { |
129 | Record r; | 156 | Record r; |
130 | read( s, r ); | 157 | memset( &r, 0, sizeof(r) ); |
131 | while( aChannel.getSize() < r.uRequestId ) | 158 | // try |
132 | aChannel.append( NULL ); | 159 | // { |
160 | read( s, r ); | ||
161 | // } | ||
162 | // catch( Bu::ExceptionBase &e ) | ||
163 | // { | ||
164 | // sio << "Error: " << e.what() << ", " << s.isOpen() << | ||
165 | // sio.nl; | ||
166 | // continue; | ||
167 | // } | ||
133 | Channel *pChan = NULL; | 168 | Channel *pChan = NULL; |
134 | if( r.uRequestId > 0 ) | 169 | if( r.uRequestId > 0 ) |
135 | pChan = aChannel[r.uRequestId-1]; | 170 | { |
171 | if( !hasChannel( r.uRequestId ) && | ||
172 | r.uType != typeBeginRequest ) | ||
173 | { | ||
174 | sio << "Error, stream data without stream." << sio.nl; | ||
175 | sio << r << sio.nl; | ||
176 | if( r.uContentLength > 0 ) | ||
177 | { | ||
178 | char *buf = new char[r.uContentLength]; | ||
179 | sio << " (read " << s.read( buf, r.uContentLength ) | ||
180 | << "/" << r.uContentLength << "):" << sio.nl; | ||
181 | sio.write( buf, r.uContentLength ); | ||
182 | sio << sio.nl << sio.nl; | ||
183 | } | ||
184 | } | ||
185 | while( aChannel.getSize() < r.uRequestId ) | ||
186 | aChannel.append( NULL ); | ||
187 | if( r.uRequestId > 0 ) | ||
188 | pChan = aChannel[r.uRequestId-1]; | ||
189 | } | ||
136 | 190 | ||
137 | sio << "Record (id=" << r.uRequestId << ", len=" << | 191 | sio << "Record (id=" << r.uRequestId << ", len=" << |
138 | r.uContentLength << ", pad=" << | 192 | r.uContentLength << ", pad=" << |
139 | (int)r.uPaddingLength << "): "; | 193 | (unsigned int)r.uPaddingLength << "): "; |
140 | fflush( stdout ); | 194 | fflush( stdout ); |
141 | 195 | ||
142 | switch( (RequestType)r.uType ) | 196 | switch( (RequestType)r.uType ) |
@@ -180,9 +234,16 @@ void Bu::FastCgi::run() | |||
180 | else | 234 | else |
181 | { | 235 | { |
182 | char *buf = new char[r.uContentLength]; | 236 | char *buf = new char[r.uContentLength]; |
183 | sio << " (read " << s.read( buf, r.uContentLength ) | 237 | int iTotal = 0; |
184 | << ")"; | 238 | do |
185 | pChan->sStdIn.append( buf, r.uContentLength ); | 239 | { |
240 | size_t iRead = s.read( | ||
241 | buf, r.uContentLength-iTotal ); | ||
242 | iTotal += iRead; | ||
243 | sio << " (read " << iRead << " " << iTotal | ||
244 | << "/" << r.uContentLength << ")"; | ||
245 | pChan->sStdIn.append( buf, iRead ); | ||
246 | } while( iTotal < r.uContentLength ); | ||
186 | delete[] buf; | 247 | delete[] buf; |
187 | } | 248 | } |
188 | break; | 249 | break; |
@@ -219,6 +280,7 @@ void Bu::FastCgi::run() | |||
219 | { | 280 | { |
220 | if( pChan->uFlags == chflgAllDone ) | 281 | if( pChan->uFlags == chflgAllDone ) |
221 | { | 282 | { |
283 | sio << "All done, generating output." << sio.nl; | ||
222 | Bu::MemBuf mStdOut, mStdErr; | 284 | Bu::MemBuf mStdOut, mStdErr; |
223 | int iRet = request( | 285 | int iRet = request( |
224 | pChan->hParams, pChan->sStdIn, | 286 | pChan->hParams, pChan->sStdIn, |
@@ -229,27 +291,47 @@ void Bu::FastCgi::run() | |||
229 | Bu::FString &sStdErr = mStdErr.getString(); | 291 | Bu::FString &sStdErr = mStdErr.getString(); |
230 | 292 | ||
231 | Record rOut; | 293 | Record rOut; |
294 | memset( &rOut, 0, sizeof(rOut) ); | ||
232 | rOut.uVersion = 1; | 295 | rOut.uVersion = 1; |
233 | rOut.uRequestId = r.uRequestId; | 296 | rOut.uRequestId = r.uRequestId; |
234 | rOut.uPaddingLength = 0; | 297 | rOut.uPaddingLength = 0; |
298 | rOut.uType = typeStdOut; | ||
235 | if( sStdOut.getSize() > 0 ) | 299 | if( sStdOut.getSize() > 0 ) |
236 | { | 300 | { |
237 | rOut.uType = typeStdOut; | 301 | for( int iPos = 0; iPos < sStdOut.getSize(); |
238 | rOut.uContentLength = sStdOut.getSize(); | 302 | iPos += 65528 ) |
239 | write( s, rOut ); | 303 | { |
240 | s.write( sStdOut ); | 304 | int iSize = sStdOut.getSize()-iPos; |
305 | if( iSize > 65528 ) | ||
306 | iSize = 65528; | ||
307 | rOut.uContentLength = iSize; | ||
308 | write( s, rOut ); | ||
309 | int iAmnt = s.write( | ||
310 | sStdOut.getStr()+iPos, iSize ); | ||
311 | sio << "Wrote " << iAmnt << | ||
312 | " of " << iSize << sio.nl; | ||
313 | } | ||
241 | } | 314 | } |
242 | rOut.uType = typeStdOut; | ||
243 | rOut.uContentLength = 0; | 315 | rOut.uContentLength = 0; |
244 | write( s, rOut ); | 316 | write( s, rOut ); |
317 | |||
318 | rOut.uType = typeStdErr; | ||
245 | if( sStdErr.getSize() > 0 ) | 319 | if( sStdErr.getSize() > 0 ) |
246 | { | 320 | { |
247 | rOut.uType = typeStdErr; | 321 | for( int iPos = 0; iPos < sStdErr.getSize(); |
248 | rOut.uContentLength = sStdErr.getSize(); | 322 | iPos += 65528 ) |
249 | write( s, rOut ); | 323 | { |
250 | s.write( sStdOut ); | 324 | int iSize = sStdErr.getSize()-iPos; |
325 | if( iSize > 65528 ) | ||
326 | iSize = 65528; | ||
327 | rOut.uContentLength = iSize; | ||
328 | write( s, rOut ); | ||
329 | int iAmnt = s.write( | ||
330 | sStdErr.getStr()+iPos, iSize ); | ||
331 | sio << "Wrote " << iAmnt << | ||
332 | " of " << iSize << sio.nl; | ||
333 | } | ||
251 | } | 334 | } |
252 | rOut.uType = typeStdErr; | ||
253 | rOut.uContentLength = 0; | 335 | rOut.uContentLength = 0; |
254 | write( s, rOut ); | 336 | write( s, rOut ); |
255 | 337 | ||
@@ -270,7 +352,8 @@ void Bu::FastCgi::run() | |||
270 | } | 352 | } |
271 | catch( Bu::SocketException &e ) | 353 | catch( Bu::SocketException &e ) |
272 | { | 354 | { |
273 | //sio << "Bu::SocketException: " << e.what() << sio.nl; | 355 | sio << "Bu::SocketException: " << e.what() << sio.nl << |
356 | "\tSocket open: " << s.isOpen() << sio.nl; | ||
274 | } | 357 | } |
275 | } | 358 | } |
276 | } | 359 | } |
diff --git a/src/fastcgi.h b/src/fastcgi.h index 83e9b83..67ec82f 100644 --- a/src/fastcgi.h +++ b/src/fastcgi.h | |||
@@ -110,11 +110,15 @@ namespace Bu | |||
110 | void write( Bu::Socket &s, Record r ); | 110 | void write( Bu::Socket &s, Record r ); |
111 | void write( Bu::Socket &s, EndRequestBody b ); | 111 | void write( Bu::Socket &s, EndRequestBody b ); |
112 | 112 | ||
113 | bool hasChannel( int iChan ); | ||
114 | |||
113 | private: | 115 | private: |
114 | Bu::ServerSocket *pSrv; | 116 | Bu::ServerSocket *pSrv; |
115 | bool bRunning; | 117 | bool bRunning; |
116 | Bu::Array<Channel *> aChannel; | 118 | Bu::Array<Channel *> aChannel; |
117 | }; | 119 | }; |
120 | |||
121 | Bu::Formatter &operator<<( Bu::Formatter &f, const Bu::FastCgi::Record &r ); | ||
118 | }; | 122 | }; |
119 | 123 | ||
120 | #endif | 124 | #endif |
diff --git a/src/fbasicstring.h b/src/fbasicstring.h index 853625c..57e798e 100644 --- a/src/fbasicstring.h +++ b/src/fbasicstring.h | |||
@@ -1297,6 +1297,38 @@ namespace Bu | |||
1297 | return !(*this == pData); | 1297 | return !(*this == pData); |
1298 | } | 1298 | } |
1299 | 1299 | ||
1300 | bool operator<(const MyType &pData ) const | ||
1301 | { | ||
1302 | flatten(); | ||
1303 | pData.flatten(); | ||
1304 | |||
1305 | const chr *a = pData.pFirst->pData; | ||
1306 | chr *b = pFirst->pData; | ||
1307 | for( long j = 0; j < nLength; j++, a++, b++ ) | ||
1308 | { | ||
1309 | if( *a != *b ) | ||
1310 | return *a < *b; | ||
1311 | } | ||
1312 | |||
1313 | return false; | ||
1314 | } | ||
1315 | |||
1316 | bool operator>(const MyType &pData ) const | ||
1317 | { | ||
1318 | flatten(); | ||
1319 | pData.flatten(); | ||
1320 | |||
1321 | const chr *a = pData.pFirst->pData; | ||
1322 | chr *b = pFirst->pData; | ||
1323 | for( long j = 0; j < nLength; j++, a++, b++ ) | ||
1324 | { | ||
1325 | if( *a != *b ) | ||
1326 | return *a > *b; | ||
1327 | } | ||
1328 | |||
1329 | return false; | ||
1330 | } | ||
1331 | |||
1300 | /** | 1332 | /** |
1301 | * Indexing operator | 1333 | * Indexing operator |
1302 | *@param nIndex (long) The index of the character you want. | 1334 | *@param nIndex (long) The index of the character you want. |
@@ -45,6 +45,9 @@ namespace Bu | |||
45 | typedef class List<value, cmpfunc, valuealloc, linkalloc> MyType; | 45 | typedef class List<value, cmpfunc, valuealloc, linkalloc> MyType; |
46 | 46 | ||
47 | public: | 47 | public: |
48 | struct const_iterator; | ||
49 | struct iterator; | ||
50 | |||
48 | List() : | 51 | List() : |
49 | pFirst( NULL ), | 52 | pFirst( NULL ), |
50 | pLast( NULL ), | 53 | pLast( NULL ), |
@@ -201,6 +204,32 @@ namespace Bu | |||
201 | } | 204 | } |
202 | } | 205 | } |
203 | 206 | ||
207 | void insert( MyType::iterator &i, const value &v ) | ||
208 | { | ||
209 | Link *pAfter = i.pLink; | ||
210 | if( pAfter == NULL ) | ||
211 | { | ||
212 | append( v ); | ||
213 | return; | ||
214 | } | ||
215 | Link *pPrev = pAfter->pPrev; | ||
216 | if( pPrev == NULL ) | ||
217 | { | ||
218 | prepend( v ); | ||
219 | return; | ||
220 | } | ||
221 | |||
222 | Link *pNew = la.allocate( 1 ); | ||
223 | pNew->pValue = va.allocate( 1 ); | ||
224 | va.construct( pNew->pValue, v ); | ||
225 | nSize++; | ||
226 | |||
227 | pNew->pNext = pAfter; | ||
228 | pNew->pPrev = pPrev; | ||
229 | pAfter->pPrev = pNew; | ||
230 | pPrev->pNext = pNew; | ||
231 | } | ||
232 | |||
204 | /** | 233 | /** |
205 | * Insert a new item in sort order by searching for the first item that | 234 | * Insert a new item in sort order by searching for the first item that |
206 | * is larger and inserting this before it, or at the end if none are | 235 | * is larger and inserting this before it, or at the end if none are |
@@ -250,7 +279,6 @@ namespace Bu | |||
250 | } | 279 | } |
251 | } | 280 | } |
252 | 281 | ||
253 | struct const_iterator; | ||
254 | /** | 282 | /** |
255 | * An iterator to iterate through your list. | 283 | * An iterator to iterate through your list. |
256 | */ | 284 | */ |
@@ -260,24 +288,30 @@ namespace Bu | |||
260 | friend class List<value, cmpfunc, valuealloc, linkalloc>; | 288 | friend class List<value, cmpfunc, valuealloc, linkalloc>; |
261 | private: | 289 | private: |
262 | Link *pLink; | 290 | Link *pLink; |
263 | MyType &rList; | 291 | MyType *pList; |
264 | bool bOffFront; | 292 | bool bOffFront; |
265 | iterator( MyType &rList ) : | 293 | iterator( MyType *pList ) : |
266 | pLink( NULL ), | 294 | pLink( NULL ), |
267 | rList( rList ) | 295 | pList( pList ) |
268 | { | 296 | { |
269 | } | 297 | } |
270 | 298 | ||
271 | iterator( Link *pLink, MyType &rList ) : | 299 | iterator( Link *pLink, MyType *pList ) : |
272 | pLink( pLink ), | 300 | pLink( pLink ), |
273 | rList( rList ) | 301 | pList( pList ) |
274 | { | 302 | { |
275 | } | 303 | } |
276 | 304 | ||
277 | public: | 305 | public: |
306 | iterator() : | ||
307 | pLink( NULL ), | ||
308 | pList( NULL ) | ||
309 | { | ||
310 | } | ||
311 | |||
278 | iterator( const iterator &i ) : | 312 | iterator( const iterator &i ) : |
279 | pLink( i.pLink ), | 313 | pLink( i.pLink ), |
280 | rList( i.rList ) | 314 | pList( i.pList ) |
281 | { | 315 | { |
282 | } | 316 | } |
283 | 317 | ||
@@ -342,7 +376,7 @@ namespace Bu | |||
342 | iterator &operator++() | 376 | iterator &operator++() |
343 | { | 377 | { |
344 | if( pLink == NULL ) | 378 | if( pLink == NULL ) |
345 | pLink = (bOffFront)?(rList.pFirst):(NULL); | 379 | pLink = (bOffFront)?(pList->pFirst):(NULL); |
346 | else | 380 | else |
347 | pLink = pLink->pNext; | 381 | pLink = pLink->pNext; |
348 | bOffFront = false; | 382 | bOffFront = false; |
@@ -352,7 +386,7 @@ namespace Bu | |||
352 | iterator &operator--() | 386 | iterator &operator--() |
353 | { | 387 | { |
354 | if( pLink == NULL ) | 388 | if( pLink == NULL ) |
355 | pLink = (bOffFront)?(NULL):(rList.pLast); | 389 | pLink = (bOffFront)?(NULL):(pList->pLast); |
356 | else | 390 | else |
357 | pLink = pLink->pPrev; | 391 | pLink = pLink->pPrev; |
358 | bOffFront = true; | 392 | bOffFront = true; |
@@ -362,7 +396,7 @@ namespace Bu | |||
362 | iterator &operator++( int ) | 396 | iterator &operator++( int ) |
363 | { | 397 | { |
364 | if( pLink == NULL ) | 398 | if( pLink == NULL ) |
365 | pLink = (bOffFront)?(rList.pFirst):(NULL); | 399 | pLink = (bOffFront)?(pList->pFirst):(NULL); |
366 | else | 400 | else |
367 | pLink = pLink->pNext; | 401 | pLink = pLink->pNext; |
368 | bOffFront = false; | 402 | bOffFront = false; |
@@ -372,7 +406,7 @@ namespace Bu | |||
372 | iterator &operator--( int ) | 406 | iterator &operator--( int ) |
373 | { | 407 | { |
374 | if( pLink == NULL ) | 408 | if( pLink == NULL ) |
375 | pLink = (bOffFront)?(NULL):(rList.pLast); | 409 | pLink = (bOffFront)?(NULL):(pList->pLast); |
376 | else | 410 | else |
377 | pLink = pLink->pPrev; | 411 | pLink = pLink->pPrev; |
378 | bOffFront = true; | 412 | bOffFront = true; |
@@ -409,24 +443,30 @@ namespace Bu | |||
409 | friend class List<value, cmpfunc, valuealloc, linkalloc>; | 443 | friend class List<value, cmpfunc, valuealloc, linkalloc>; |
410 | private: | 444 | private: |
411 | Link *pLink; | 445 | Link *pLink; |
412 | const MyType &rList; | 446 | const MyType *pList; |
413 | bool bOffFront; | 447 | bool bOffFront; |
414 | const_iterator( const MyType &rList ) : | 448 | const_iterator( const MyType *pList ) : |
415 | pLink( NULL ), | 449 | pLink( NULL ), |
416 | rList( rList ) | 450 | pList( pList ) |
417 | { | 451 | { |
418 | } | 452 | } |
419 | 453 | ||
420 | const_iterator( Link *pLink, const MyType &rList ) : | 454 | const_iterator( Link *pLink, const MyType *pList ) : |
421 | pLink( pLink ), | 455 | pLink( pLink ), |
422 | rList( rList ) | 456 | pList( pList ) |
423 | { | 457 | { |
424 | } | 458 | } |
425 | 459 | ||
426 | public: | 460 | public: |
461 | const_iterator() : | ||
462 | pLink( NULL ), | ||
463 | pList( NULL ) | ||
464 | { | ||
465 | } | ||
466 | |||
427 | const_iterator( const iterator &i ) : | 467 | const_iterator( const iterator &i ) : |
428 | pLink( i.pLink ), | 468 | pLink( i.pLink ), |
429 | rList( i.rList ) | 469 | pList( i.pList ) |
430 | { | 470 | { |
431 | } | 471 | } |
432 | 472 | ||
@@ -463,7 +503,7 @@ namespace Bu | |||
463 | const_iterator &operator++() | 503 | const_iterator &operator++() |
464 | { | 504 | { |
465 | if( pLink == NULL ) | 505 | if( pLink == NULL ) |
466 | pLink = (bOffFront)?(rList.pFirst):(NULL); | 506 | pLink = (bOffFront)?(pList->pFirst):(NULL); |
467 | else | 507 | else |
468 | pLink = pLink->pNext; | 508 | pLink = pLink->pNext; |
469 | bOffFront = false; | 509 | bOffFront = false; |
@@ -473,7 +513,7 @@ namespace Bu | |||
473 | const_iterator &operator--() | 513 | const_iterator &operator--() |
474 | { | 514 | { |
475 | if( pLink == NULL ) | 515 | if( pLink == NULL ) |
476 | pLink = (bOffFront)?(NULL):(rList.pLast); | 516 | pLink = (bOffFront)?(NULL):(pList->pLast); |
477 | else | 517 | else |
478 | pLink = pLink->pPrev; | 518 | pLink = pLink->pPrev; |
479 | bOffFront = true; | 519 | bOffFront = true; |
@@ -483,7 +523,7 @@ namespace Bu | |||
483 | const_iterator &operator++( int ) | 523 | const_iterator &operator++( int ) |
484 | { | 524 | { |
485 | if( pLink == NULL ) | 525 | if( pLink == NULL ) |
486 | pLink = (bOffFront)?(rList.pFirst):(NULL); | 526 | pLink = (bOffFront)?(pList->pFirst):(NULL); |
487 | else | 527 | else |
488 | pLink = pLink->pNext; | 528 | pLink = pLink->pNext; |
489 | bOffFront = false; | 529 | bOffFront = false; |
@@ -493,7 +533,7 @@ namespace Bu | |||
493 | const_iterator &operator--( int ) | 533 | const_iterator &operator--( int ) |
494 | { | 534 | { |
495 | if( pLink == NULL ) | 535 | if( pLink == NULL ) |
496 | pLink = (bOffFront)?(NULL):(rList.pLast); | 536 | pLink = (bOffFront)?(NULL):(pList->pLast); |
497 | else | 537 | else |
498 | pLink = pLink->pPrev; | 538 | pLink = pLink->pPrev; |
499 | bOffFront = true; | 539 | bOffFront = true; |
@@ -529,7 +569,7 @@ namespace Bu | |||
529 | */ | 569 | */ |
530 | iterator begin() | 570 | iterator begin() |
531 | { | 571 | { |
532 | return iterator( pFirst, *this ); | 572 | return iterator( pFirst, this ); |
533 | } | 573 | } |
534 | 574 | ||
535 | /** | 575 | /** |
@@ -538,7 +578,7 @@ namespace Bu | |||
538 | */ | 578 | */ |
539 | const_iterator begin() const | 579 | const_iterator begin() const |
540 | { | 580 | { |
541 | return const_iterator( pFirst, *this ); | 581 | return const_iterator( pFirst, this ); |
542 | } | 582 | } |
543 | 583 | ||
544 | /** | 584 | /** |
@@ -548,7 +588,7 @@ namespace Bu | |||
548 | */ | 588 | */ |
549 | const iterator end() | 589 | const iterator end() |
550 | { | 590 | { |
551 | return iterator( NULL, *this ); | 591 | return iterator( NULL, this ); |
552 | } | 592 | } |
553 | 593 | ||
554 | /** | 594 | /** |
@@ -558,7 +598,7 @@ namespace Bu | |||
558 | */ | 598 | */ |
559 | const const_iterator end() const | 599 | const const_iterator end() const |
560 | { | 600 | { |
561 | return const_iterator( NULL, *this ); | 601 | return const_iterator( NULL, this ); |
562 | } | 602 | } |
563 | 603 | ||
564 | /** | 604 | /** |
diff --git a/src/socket.cpp b/src/socket.cpp index a660b30..c01c63a 100644 --- a/src/socket.cpp +++ b/src/socket.cpp | |||
@@ -369,7 +369,7 @@ bool Bu::Socket::isSeekable() | |||
369 | bool Bu::Socket::isBlocking() | 369 | bool Bu::Socket::isBlocking() |
370 | { | 370 | { |
371 | #ifndef WIN32 | 371 | #ifndef WIN32 |
372 | return ((fcntl( nSocket, F_GETFL, 0 ) & O_NONBLOCK) == O_NONBLOCK); | 372 | return ((fcntl( nSocket, F_GETFL, 0 ) & O_NONBLOCK) != O_NONBLOCK); |
373 | #else | 373 | #else |
374 | return false; | 374 | return false; |
375 | #endif | 375 | #endif |
@@ -380,7 +380,7 @@ void Bu::Socket::setBlocking( bool bBlocking ) | |||
380 | #ifndef WIN32 | 380 | #ifndef WIN32 |
381 | if( bBlocking ) | 381 | if( bBlocking ) |
382 | { | 382 | { |
383 | fcntl( nSocket, F_SETFL, fcntl( nSocket, F_GETFL, 0 ) & ~O_NONBLOCK ); | 383 | fcntl( nSocket, F_SETFL, fcntl( nSocket, F_GETFL, 0 ) & (~O_NONBLOCK) ); |
384 | } | 384 | } |
385 | else | 385 | else |
386 | { | 386 | { |