~ubuntu-branches/ubuntu/quantal/zeroc-ice/quantal

« back to all changes in this revision

Viewing changes to java/src/Ice/ConnectionI.java

  • Committer: Bazaar Package Importer
  • Author(s): Cleto Martín
  • Date: 2011-06-25 19:44:26 UTC
  • mfrom: (6.1.16 sid)
  • Revision ID: james.westby@ubuntu.com-20110625194426-9fip3u3hlwheohvl
Tags: 3.4.2-1
New upstream release (Closes: #631456).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
// **********************************************************************
2
2
//
3
 
// Copyright (c) 2003-2010 ZeroC, Inc. All rights reserved.
 
3
// Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved.
4
4
//
5
5
// This copy of Ice is licensed to you under the terms described in the
6
6
// ICE_LICENSE file included in this distribution.
1067
1067
                    {
1068
1068
                        info = parseMessage(current.stream); // Optimization: use the thread's stream.
1069
1069
                    }
 
1070
 
 
1071
                    //
 
1072
                    // We increment the dispatch count to prevent the
 
1073
                    // communicator destruction during the callback.
 
1074
                    //
 
1075
                    if(sentCBs != null || info != null && info.outAsync != null)
 
1076
                    {
 
1077
                        ++_dispatchCount;
 
1078
                    }
1070
1079
                }
1071
1080
            }
1072
1081
            catch(DatagramLimitException ex) // Expected.
1200
1209
                          info.adapter);
1201
1210
            }
1202
1211
        }
 
1212
        
 
1213
        //
 
1214
        // Decrease dispatch count.
 
1215
        //
 
1216
        if(sentCBs != null || info != null && info.outAsync != null)
 
1217
        {
 
1218
            synchronized(this)
 
1219
            {
 
1220
                if(--_dispatchCount == 0)
 
1221
                {
 
1222
                    if(_state == StateClosing)
 
1223
                    {
 
1224
                        try
 
1225
                        {
 
1226
                            initiateShutdown();
 
1227
                        }
 
1228
                        catch(LocalException ex)
 
1229
                        {
 
1230
                            setState(StateClosed, ex);
 
1231
                        }
 
1232
                    }
 
1233
                    else if(_state == StateFinished)
 
1234
                    {
 
1235
                        _reaper.add(this);
 
1236
                    }
 
1237
                    notifyAll();
 
1238
                }
 
1239
            }
 
1240
        }
1203
1241
    }
1204
1242
 
1205
1243
    public void
1263
1301
            _startCallback = null;
1264
1302
        }
1265
1303
        
1266
 
        //
1267
 
        // NOTE: for twoway requests which are not sent, finished can be called twice: the 
1268
 
        // first time because the outgoing is in the _sendStreams set and the second time 
1269
 
        // because it's either in the _requests/_asyncRequests set. This is fine, only the 
1270
 
        // first call should be taken into account by the implementation of finished.
1271
 
        //
1272
 
        
1273
 
        for(OutgoingMessage p : _sendStreams)
 
1304
        if(!_sendStreams.isEmpty())
1274
1305
        {
1275
 
            if(p.requestId > 0)
 
1306
            //
 
1307
            // Return the stream to the outgoing call. This is important for 
 
1308
            // retriable AMI calls which are not marshalled again.
 
1309
            //
 
1310
            OutgoingMessage message = _sendStreams.getFirst();
 
1311
            _writeStream.swap(message.stream);
 
1312
        
 
1313
            //
 
1314
            // NOTE: for twoway requests which are not sent, finished can be called twice: the 
 
1315
            // first time because the outgoing is in the _sendStreams set and the second time 
 
1316
            // because it's either in the _requests/_asyncRequests set. This is fine, only the 
 
1317
            // first call should be taken into account by the implementation of finished.
 
1318
            //
 
1319
            for(OutgoingMessage p : _sendStreams)
1276
1320
            {
1277
 
                if(p.out != null) // Make sure finished isn't called twice.
1278
 
                {
1279
 
                    _requests.remove(p.requestId);
1280
 
                }
1281
 
                else
1282
 
                {
1283
 
                    _asyncRequests.remove(p.requestId);
1284
 
                }
 
1321
                if(p.requestId > 0)
 
1322
                {
 
1323
                    if(p.out != null) // Make sure finished isn't called twice.
 
1324
                    {
 
1325
                        _requests.remove(p.requestId);
 
1326
                    }
 
1327
                    else
 
1328
                    {
 
1329
                        _asyncRequests.remove(p.requestId);
 
1330
                    }
 
1331
                }
 
1332
                p.finished(_exception);
1285
1333
            }
1286
 
            p.finished(_exception);
 
1334
            _sendStreams.clear();
1287
1335
        }
1288
 
        _sendStreams.clear();
1289
1336
        
1290
1337
        for(IceInternal.Outgoing p : _requests.values())
1291
1338
        {
1503
1550
        }
1504
1551
        catch(java.lang.Exception ex)
1505
1552
        {
1506
 
            Ice.SyscallException e = new Ice.SyscallException();
1507
 
            e.initCause(ex);
1508
 
            throw e;
 
1553
            throw new Ice.SyscallException(ex);
1509
1554
        }
1510
1555
    }
1511
1556
 
2329
2374
        }
2330
2375
        catch(java.lang.AssertionError ex) // Upon assertion, we print the stack trace.
2331
2376
        {
2332
 
            UnknownException uex = new UnknownException();
 
2377
            UnknownException uex = new UnknownException(ex);
2333
2378
            java.io.StringWriter sw = new java.io.StringWriter();
2334
2379
            java.io.PrintWriter pw = new java.io.PrintWriter(sw);
2335
2380
            ex.printStackTrace(pw);
2340
2385
        }
2341
2386
        catch(java.lang.OutOfMemoryError ex)
2342
2387
        {
2343
 
            UnknownException uex = new UnknownException();
 
2388
            UnknownException uex = new UnknownException(ex);
2344
2389
            java.io.StringWriter sw = new java.io.StringWriter();
2345
2390
            java.io.PrintWriter pw = new java.io.PrintWriter(sw);
2346
2391
            ex.printStackTrace(pw);