~ubuntu-branches/ubuntu/feisty/ncbi-tools6/feisty

« back to all changes in this revision

Viewing changes to connect/ncbi_connection.c

  • Committer: Bazaar Package Importer
  • Author(s): Barry deFreese
  • Date: 2006-07-19 23:28:07 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20060719232807-et3cdmcjgmnyleyx
Tags: 6.1.20060507-3ubuntu1
Re-merge with Debian

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*  $Id: ncbi_connection.c,v 6.45 2005/05/18 18:15:21 lavr Exp $
 
1
/*  $Id: ncbi_connection.c,v 6.48 2006/02/23 17:43:01 lavr Exp $
2
2
 * ===========================================================================
3
3
 *
4
4
 *                            PUBLIC DOMAIN NOTICE
53
53
             : "Unknown", IO_StatusStr(status)))
54
54
 
55
55
#define CONN_LOG(level, descr)  CONN_LOG_EX(level, descr, status)
56
 
 
 
56
#ifdef _DEBUG
 
57
#  define CONN_TRACE(descr)  CONN_LOG(eLOG_Trace, descr)
 
58
#else
 
59
#  define CONN_TRACE(descr)  ((void) 0)
 
60
#endif /*_DEBUG*/
57
61
 
58
62
/* Standard macros to verify that the passed connection handle is not NULL
59
63
 */
262
266
extern EIO_Status CONN_SetTimeout
263
267
(CONN            conn,
264
268
 EIO_Event       event,
265
 
 const STimeout* new_timeout)
 
269
 const STimeout* timeout)
266
270
{
267
271
    EIO_Status status = eIO_Success;
268
272
 
270
274
 
271
275
    switch (event) {
272
276
    case eIO_Open:
273
 
        if (new_timeout  &&  new_timeout != kDefaultTimeout) {
274
 
            conn->oo_timeout = *new_timeout;
 
277
        if (timeout  &&  timeout != kDefaultTimeout) {
 
278
            if (&conn->oo_timeout != timeout)
 
279
                conn->oo_timeout = *timeout;
275
280
            conn->o_timeout  = &conn->oo_timeout;
276
281
        } else {
277
 
            conn->o_timeout  = new_timeout;
 
282
            conn->o_timeout  = timeout;
278
283
        }
279
284
        break;
280
285
    case eIO_Close:
281
 
        if (new_timeout  &&  new_timeout != kDefaultTimeout) {
282
 
            conn->cc_timeout = *new_timeout;
 
286
        if (timeout  &&  timeout != kDefaultTimeout) {
 
287
            if (&conn->cc_timeout != timeout)
 
288
                conn->cc_timeout = *timeout;
283
289
            conn->c_timeout  = &conn->cc_timeout;
284
290
        } else {
285
 
            conn->c_timeout  = new_timeout;
 
291
            conn->c_timeout  = timeout;
286
292
        }
287
293
        break;
288
294
    case eIO_Read:
289
295
    case eIO_ReadWrite:
290
 
        if (new_timeout  &&  new_timeout != kDefaultTimeout) {
291
 
            conn->rr_timeout = *new_timeout;
 
296
        if (timeout  &&  timeout != kDefaultTimeout) {
 
297
            if (&conn->rr_timeout != timeout)
 
298
                conn->rr_timeout = *timeout;
292
299
            conn->r_timeout  = &conn->rr_timeout;
293
300
        } else {
294
 
            conn->r_timeout  = new_timeout;
 
301
            conn->r_timeout  = timeout;
295
302
        }
296
303
        if (event != eIO_ReadWrite)
297
304
            break;
298
305
        /*FALLTHRU*/
299
306
    case eIO_Write:
300
 
        if (new_timeout  &&  new_timeout != kDefaultTimeout) {
301
 
            conn->ww_timeout = *new_timeout;
 
307
        if (timeout  &&  timeout != kDefaultTimeout) {
 
308
            if (&conn->ww_timeout != timeout)
 
309
                conn->ww_timeout = *timeout;
302
310
            conn->w_timeout  = &conn->ww_timeout;
303
311
        } else {
304
 
            conn->w_timeout  = new_timeout;
 
312
            conn->w_timeout  = timeout;
305
313
        }
306
314
        break;
307
315
    default:
406
414
    /* call current connector's "WRITE" method */
407
415
    status = conn->meta.write(conn->meta.c_write, buf, size, n_written,
408
416
                              conn->w_timeout == kDefaultTimeout ?
409
 
                              conn->meta.default_timeout :conn->w_timeout);
 
417
                              conn->meta.default_timeout : conn->w_timeout);
410
418
 
411
419
    if (status != eIO_Success) {
412
420
        if ( *n_written ) {
413
 
            CONN_LOG(eLOG_Trace, "[CONN_Write]  Write error");
 
421
            CONN_TRACE("[CONN_Write]  Write error");
414
422
            status = eIO_Success;
415
423
        } else if ( size )
416
424
            CONN_LOG(eLOG_Error, "[CONN_Write]  Cannot write data");
562
570
 
563
571
    if (status != eIO_Success) {
564
572
        if ( *n_read ) {
565
 
            CONN_LOG(eLOG_Trace, "[CONN_Read]  Read error");
 
573
            CONN_TRACE("[CONN_Read]  Read error");
566
574
            status = eIO_Success;
567
 
        } else if ( size ) {
568
 
            CONN_LOG(status == eIO_Closed  ? eLOG_Trace   :
569
 
                     status == eIO_Timeout ? eLOG_Warning : eLOG_Error,
 
575
        } else if (size  &&  status != eIO_Closed) {
 
576
            CONN_LOG(status == eIO_Timeout ? eLOG_Warning : eLOG_Error,
570
577
                     "[CONN_Read]  Cannot read data");
571
578
        }
572
579
    }
855
862
/*
856
863
 * --------------------------------------------------------------------------
857
864
 * $Log: ncbi_connection.c,v $
 
865
 * Revision 6.48  2006/02/23 17:43:01  lavr
 
866
 * CONN_Read():  No CLOSED trace on EOF
 
867
 *
 
868
 * Revision 6.47  2006/02/14 15:49:42  lavr
 
869
 * Introduce and use CORE_TRACE macros (NOP in Release mode)
 
870
 *
 
871
 * Revision 6.46  2006/01/18 03:38:17  lavr
 
872
 * Prevent copying STimeout structs into themselves [where can occur]
 
873
 *
858
874
 * Revision 6.45  2005/05/18 18:15:21  lavr
859
875
 * Formatting spot
860
876
 *
923
939
 * Checks for kDefaultTimeout and use of default_timeout of meta-connector
924
940
 *
925
941
 * Revision 6.23  2002/04/24 21:18:04  lavr
926
 
 * Beautifying: pup open check before buffer check in CONN_Wait()
 
942
 * Beautifying: move open check in front of buffer check in CONN_Wait()
927
943
 *
928
944
 * Revision 6.22  2002/04/22 19:30:01  lavr
929
945
 * Do not put trace message on polling wait (tmo={0,0})
991
1007
 *
992
1008
 * Revision 6.2  2000/12/29 17:52:59  lavr
993
1009
 * Adapted to use new connector structure; modified to have
994
 
 * Internal tri-state {Unusable | Open | Closed }.
 
1010
 * an internal tri-state {Unusable | Open | Closed }.
995
1011
 *
996
1012
 * Revision 6.1  2000/03/24 22:53:34  vakatov
997
1013
 * Initial revision