Commit 2e1bc853a1564bfee773519a8ef23da4bf1eb1f1

Authored by perry.werneck@gmail.com
1 parent 648b777f

Movendo cleanup do socket para uma thread independente

Showing 1 changed file with 39 additions and 31 deletions   Show diff stats
android/src/br/com/bb/pw3270/lib3270.java
... ... @@ -541,43 +541,51 @@ public abstract class lib3270
541 541  
542 542 private int net_cleanup()
543 543 {
544   - Log.v(TAG, "Stopping network activity");
545   -
546 544 if(sock != null)
547 545 {
548   - if(sock.isConnected())
  546 + Thread t = new Thread()
549 547 {
550   - try
551   - {
552   - sock.shutdownInput();
553   - return 0;
554   - }
555   - catch(Exception e)
  548 + public void run()
556 549 {
557   - String msg = e.getLocalizedMessage();
558   - if(msg == null)
559   - msg = e.getMessage();
560   -
561   - Log.v(TAG,": shutdownInput error" + (msg != null ? msg : e.toString()));
562   - }
563   - }
  550 + Log.v(TAG, "Stopping network activity");
  551 +
  552 + if(sock.isConnected())
  553 + {
  554 + try
  555 + {
  556 + sock.shutdownInput();
  557 + }
  558 + catch(Exception e)
  559 + {
  560 + String msg = e.getLocalizedMessage();
  561 + if(msg == null)
  562 + msg = e.getMessage();
564 563  
565   - if(!sock.isClosed())
566   - {
567   - try
568   - {
569   - sock.close();
570   - return 0;
571   - }
572   - catch(Exception e)
573   - {
574   - String msg = e.getLocalizedMessage();
575   - if(msg == null)
576   - msg = e.getMessage();
577   -
578   - Log.v(TAG,"sockclose error: " + (msg != null ? msg : e.toString()));
  564 + Log.v(TAG,": shutdownInput error" + (msg != null ? msg : e.toString()));
  565 + }
  566 + }
  567 +
  568 + /*
  569 + if!(sock == null && sock.isClosed()))
  570 + {
  571 + try
  572 + {
  573 + sock.close();
  574 + }
  575 + catch(Exception e)
  576 + {
  577 + String msg = e.getLocalizedMessage();
  578 + if(msg == null)
  579 + msg = e.getMessage();
  580 +
  581 + Log.v(TAG,"sockclose error: " + (msg != null ? msg : e.toString()));
  582 + }
  583 + }
  584 + */
579 585 }
580   - }
  586 + };
  587 +
  588 + t.start();
581 589 }
582 590  
583 591 return 0;
... ...