After SocketChannel.close, must call Selector.wakeup

When I am reading from a tcp socket using NIO channels & selectors, I have the following problem when I go to close the channel.
If I close the channel in the thread where I called selector.select(), then the channel is closed and the client application gets the event that the channel was closed.
However, if I do the reading in a seperate thread, after calling channel.close(), I must call selector.wakeup() or the socket is not closed.
Any idea what is going on?
thanks - dave

The main point of NIO is that you don't need multiple threads to read and write multiple sockets. You can use multiple threads, but it complicates things. After you close a channel you must let the select run one more time, this is the reason that I try to close channels from the thread that is running the select. You probably already have a queue of runnables to process interestOps and register in the select thread. You should use that for the close activity as well.
I've posted a lot of topics on NIO, that cover this and other tricks of using NIO. Here are the most useful.
Taming the NIO Circus, NIO Server Example, NIO Client Example

Similar Messages

  • SQLException: After clearParameters() has been called, all parameters must be reset before executing

    Hi,
    I am running: Weblogic 6.1, SP2
    Driver : weblogic.jdbc.oci.Driver
    Reason for not using the "thin" driver, which works, is limit
    on size of Clob
    Previous references to this problem in this newsgroup indicate driver problems
    with older versions of WL.. I am using the latest..
    The SQLException I get is "After clearParameters() has been called, all parameters
    must be reset before executing". This happens the second time the code below is
    excuted ( ok the first time )
    "clearParameters()" is never called explicitly in my code.
    The exception occurs on the "spFunc.execute();" statement at the very end of this
    code:
    // OBS:connection, conn_, is opened from a connection pool
    before this code is called and cloesed afterwards.
    conn_.setAutoCommit(false);
    // ============== Initializing clob ==================
    SerialStatement stmt = (SerialStatement)conn_.createStatement();
    stmt.execute("INSERT INTO lc_clob_temp VALUES (1, EMPTY_CLOB())");
    // OBS: using a prepared statement here will result in SerialClob
    // exception when using setClob in the prepared statement
    below
    // This is probably a bug ( worked in WL 5.1 ). We had this
    as a support case 270952 with WebLogic.
    stmt.execute("SELECT * FROM lc_clob_temp WHERE id = 1");
    ResultSet crs = stmt.getResultSet();
    weblogic.jdbc.rmi.SerialClob xmlClob = null;
    while ( crs.next() ) {
    xmlClob=(weblogic.jdbc.rmi.SerialClob)crs.getClob("newclob");
    // Call Oracle's stored procedure for calling Oracle XSU.
    SerialCallableStatement spFunc =
    (SerialCallableStatement)conn_.prepareCall(
    "declare " +
    "insCtx sys.DBMS_XMLSave.ctxType; " +
    "begin " +
    "insCtx := sys.DBMS_XMLSave.newContext(?); " +
         "sys.DBMS_XMLSave.setBatchSize(insCtx,0);" +      "sys.DBMS_XMLSave.setCommitBatch(insCtx,
    0);" +
    "? := sys.DBMS_XMLSave.insertXML(insCtx,?); " +
    "sys.DBMS_XMLSave.closeContext(insCtx); " +
    "end;"
    spFunc.setString(1, viewName );
    spFunc.registerOutParameter (2, Types.NUMERIC);
    Writer outstream = xmlClob.getCharacterOutputStream();
    outstream.write(xml.toString());
    outstream.flush();
    outstream.close();
    spFunc.setClob( 3, xmlClob);
    spFunc.execute();
    spFunc.close();

    Hi,
    I am running: Weblogic 6.1, SP2
    Driver : weblogic.jdbc.oci.Driver
    Reason for not using the "thin" driver, which works, is limit
    on size of Clob
    Previous references to this problem in this newsgroup indicate driver problems
    with older versions of WL.. I am using the latest..
    The SQLException I get is "After clearParameters() has been called, all parameters
    must be reset before executing". This happens the second time the code below is
    excuted ( ok the first time )
    "clearParameters()" is never called explicitly in my code.
    The exception occurs on the "spFunc.execute();" statement at the very end of this
    code:
    // OBS:connection, conn_, is opened from a connection pool
    before this code is called and cloesed afterwards.
    conn_.setAutoCommit(false);
    // ============== Initializing clob ==================
    SerialStatement stmt = (SerialStatement)conn_.createStatement();
    stmt.execute("INSERT INTO lc_clob_temp VALUES (1, EMPTY_CLOB())");
    // OBS: using a prepared statement here will result in SerialClob
    // exception when using setClob in the prepared statement
    below
    // This is probably a bug ( worked in WL 5.1 ). We had this
    as a support case 270952 with WebLogic.
    stmt.execute("SELECT * FROM lc_clob_temp WHERE id = 1");
    ResultSet crs = stmt.getResultSet();
    weblogic.jdbc.rmi.SerialClob xmlClob = null;
    while ( crs.next() ) {
    xmlClob=(weblogic.jdbc.rmi.SerialClob)crs.getClob("newclob");
    // Call Oracle's stored procedure for calling Oracle XSU.
    SerialCallableStatement spFunc =
    (SerialCallableStatement)conn_.prepareCall(
    "declare " +
    "insCtx sys.DBMS_XMLSave.ctxType; " +
    "begin " +
    "insCtx := sys.DBMS_XMLSave.newContext(?); " +
         "sys.DBMS_XMLSave.setBatchSize(insCtx,0);" +      "sys.DBMS_XMLSave.setCommitBatch(insCtx,
    0);" +
    "? := sys.DBMS_XMLSave.insertXML(insCtx,?); " +
    "sys.DBMS_XMLSave.closeContext(insCtx); " +
    "end;"
    spFunc.setString(1, viewName );
    spFunc.registerOutParameter (2, Types.NUMERIC);
    Writer outstream = xmlClob.getCharacterOutputStream();
    outstream.write(xml.toString());
    outstream.flush();
    outstream.close();
    spFunc.setClob( 3, xmlClob);
    spFunc.execute();
    spFunc.close();

  • Calling DbEnv- remove after DbEnv- close results in a segmentation fault

    I have two classes of database files: definitions that change slowly, and instances that are transient and change quickly.
    What I'm trying to do is this:
    close databases, environment
    back up files
    remove instance databases
    open new environment, existing definitions and create new instances
    This keeps returning ENOENT errors, but not consistently. The results are unpredictable and will sometimes hang. It seems to me that this is due to something in the environment not being cleared correctly. So I tried adding a remove after a close, and I get a regular and consistent segment fault as the unwrap function in cxx_env.cpp returns a NULL environment.
    This behaviour is consistent in versions 4.3, 4.5, and 4.7 on Solaris 10 and RHEL 5.
    So my question is twofold: Is there a better way to do what I'm tying to do, on that will work reliably, and shouldn't the remove operation work, even if ther's nothing to remove? I've had this problem for quite some time so any pointers would be appreciated.
    TIA,
    Dave

    Sorry. I had a major attack of the stupids. I was using old code that unlinked the underlying files instead of using a db->remove. It works much better now.

  • Set Cursor.vi fails after it has been called for 30 different panel refs in LV 7.1.1

    Make sure both attached files (Run LabVIEW_Cursor_TestCase.vi, SimpleVI.vi) are in the same folder. Run LabVIEW_Cursor_TestCase.vi notice that the -3 error code is returned from "Set Cursor.vi" after it has been called with 30 different panel refs. If "Set Cursor.vi" is replaced with "Set Busy.vi" the same error occurs.Is there a workaround for this problem other that setting the cursor image manually in user32.dll? I must be able to open more than 30 panels and set them all to busy. In the test case I used a single VI, simply to demonstrate the error.
    Message Edited by Jerred on 05-04-2007 10:06 AM
    Attachments:
    LabVIEW_Cursor_TestCase.vi ‏68 KB
    SimpleVI.vi ‏13 KB

    This bug is fixed in LabVIEW 8.0 and later.  Unfortunately, I know of no workaround in LabVIEW 7.x.  When I encountered this bug in one of my UIs in LabVIEW 7.x, my "fix" was simply to ignore the error outputs from the cursor VIs, and to live with the fact that I had no custom cursors after 30 windows had been opened.
    -D
    Darren Nattinger, CLA
    LabVIEW Artisan and Nugget Penman

  • Muse JS Assert: Error calling selector function:Type error: Object has no method Muse Menu

    When exporting html and viewing locally we receive the following error... This error disappears after removing menu from top of page. This error does not occur when viewed on Outdoors360.businesscatalyst.com (our temporary site)
    Muse JS Assert: Error calling selector function:Type error: Object has no method Muse Menu
    Any ideas??

    I fix the problem.
    I have carefully reviewed JAVASCRIPT files and I could see that these are not a major influence within the site, only are reference code and utilities of the same application.
    By removing these files nothing has stopped working, I thought I would have some error in the sliders, or opacities, but no, nothing happened.
    DELETE IT
    FRANCISCO CATALDO DISEÑADOR GRÁFICO

  • A Runtime error: Generation successful, but you must call up the function

    I used Professor Jim Menching's AIS materials in fall 2009 before ECC 6.04 was installed and everything worked plug-n-play without too many problems.  I tested assigned client after my client provider migrated SAP from ECC 6.0 to 6.04. 
    I tried to proceeded "receive the product from the vendor" on page 13u2019s step 11 after creating an purchase order, as following:
    Logistics> Materials Management > Purchasing > Purchase Order > Follow-on Functions > Logistics Invoice Verification  (MIRO)
    I tried to save it.  However, I got an error message: "Generation successful, but you must call up the function".  After I did it one more time, it becomes a runtime error!  I am not savvy for dealing with unknown technical problem.  Can anyone provide me with a solution to fix problem?
    Thanks in advance.

    Picheng,
    Thanks for the post.  I forwarded your question to your hosting site for resolution since this is a technical issue ... and the technical team informed me the issue was already resolved.  If you have further issues related to this specific issue please contact the UCC directly.
    Best Regards,
    Heather

  • Itunes keeps reopens by itself after i close it on xp

    Has anyone out there been able to figure out why and how to stop itunes from reopening itself after you close it on windows XP. This is an xp ? so please don't post mac os answers. From what I read and heard from support, no-one at apple knows why this is happening. I used itunes to legaly buy and download music. I do own an ipod and therefore don't connect one to my computer. I have a feeling it has to do with the ipodservice and or the itunes helper service that seem to ignore the fact that I have disabled them in services.msc. But nothing works. I will listen to some music via itunes, download some from the store, etc.. When I am done I will try file/exit, or closing via the x in the top right corner. Then suddenly the software reopens... I dont want to have to stop using itunes, but I can not get a fix for this I may just have to switch over to rhapsody via windows media player. Appkle tech support said they couldnt help me and didnt know why it works. Thats sad cause I spend a lot of money on intunes and if they dont care about me, then i can only assume they will treat me the same if I bought one of thier computers. Looks like they lose a customer here..... Any insights would much be appreciated. Links from previous post anything that might help me fix this issue that apple says too bad your a pc user.
    Message was edited by: KokoAtae
    Message was edited by: KokoAtae

    I'm having the exact same problem in Windows Vista. It has only happened since the last update to iTunes; it didn't happen before that. It happens ever five minute or so and is making me insane. Of course, I can't delete iTunes, since that's where my iPod library resides. Somebody MUST do something about this. Can anyone help?

  • Playing a WAVE file after making a phone call.

    Hi everyone..
    I'm trying to play a wav file after making a phone call. I was able to make the call. But I get an exception when i try to paly a wav file..
    Can any one tell me where I've gone wrong..
    This is the code which plays the audio file..(I downloaded it by the way.. and it's working fine when used as a seperate program)
    import java.io.File;
    import java.io.IOException;
    import javax.sound.sampled.AudioFormat;
    import javax.sound.sampled.AudioInputStream;
    import javax.sound.sampled.AudioSystem;
    import javax.sound.sampled.DataLine;
    import javax.sound.sampled.FloatControl;
    import javax.sound.sampled.LineUnavailableException;
    import javax.sound.sampled.SourceDataLine;
    import javax.sound.sampled.UnsupportedAudioFileException;
    public class PlayWave extends Thread {
         private String filename;
         private Position curPosition;
    //30000000(7324.21 kb)
         private final int EXTERNAL_BUFFER_SIZE = 524288; // 128Kb
         enum Position {
              LEFT, RIGHT, NORMAL
         public PlayWave(String wavfile) {
              filename = wavfile;
              curPosition = Position.NORMAL;
         public PlayWave(String wavfile, Position p) {
              filename = wavfile;
              curPosition = p;
         public void run() {
              File soundFile = new File(filename);
              if (!soundFile.exists()) {
                   System.err.println("Wave file not found: " + filename);
                   return;
              AudioInputStream audioInputStream = null;
              try {
                   audioInputStream = AudioSystem.getAudioInputStream(soundFile);
              } catch (UnsupportedAudioFileException e1) {
                   e1.printStackTrace();
                   return;
              } catch (IOException e1) {
                   e1.printStackTrace();
                   return;
              AudioFormat format = audioInputStream.getFormat();
              SourceDataLine auline = null;
              DataLine.Info info = new DataLine.Info(SourceDataLine.class, format);
              try {
                   auline = (SourceDataLine) AudioSystem.getLine(info);
                   auline.open(format);
              } catch (LineUnavailableException e) {
                   e.printStackTrace();
                   return;
              } catch (Exception e) {
                   e.printStackTrace();
                   return;
              if (auline.isControlSupported(FloatControl.Type.PAN)) {
         FloatControl pan = (FloatControl) auline.getControl(FloatControl.Type.PAN);
                   if (curPosition == Position.RIGHT)
                        pan.setValue(1.0f);
                   else if (curPosition == Position.LEFT)
                        pan.setValue(-1.0f);
              auline.start();
              int nBytesRead = 0;
              byte[] abData = new byte[EXTERNAL_BUFFER_SIZE];
              try {
                   while (nBytesRead != -1) {
              nBytesRead = audioInputStream.read(abData, 0, abData.length);
              if (nBytesRead >= 0)
                   auline.write(abData, 0, nBytesRead);
              } catch (IOException e) {
                   e.printStackTrace();
                   return;
              } finally {
                   auline.drain();
                   auline.close();
         }I inserted
    new PlayWave("greeting.wav").start();In to a method an called this method in the program where i send commands to the modem.
    These are my modem commands
    send("ATZ");
        expect("OK");
    //Enable voice mode
        send("AT+FCLASS=8");
        expect("OK");
    //Dial the number
        send("ATDT"+number);
        expect("OK");
    //Choose encoding method //This is the default
        send("AT+VSM=140,8000,0,0");
        expect("OK");
    // start sending audio data
        send("AT+VTX");
        expect("OK");
    PlayAudio();
    send("ATH");The size of my audio file is 100 kb.I'm using a 56 K intel externel voice modem connected to a serial port.I wonder if it's because the buffer is too big. If anyone tried this and succeded please correct me.
    Thankyou in advance
    goodnews

    Hi goodnews!
    Did I understand well? Can You record the speech? This is what I want!
    Can you help me and send me sample code?
    This would be a big help for me!
    Thank You!
    rflair

  • MuseJSAssert: Error calling selector function:ReferenceError: Spry is not defined.

    I launched Muse today and it said there was an updated available. I installed it and then made a few small changes to my 5 page website. Then i exported the HTML and uploaded it to my server.
    But now when i try browsing the site in Chrome, I get the following error message:
    MuseJSAssert: Error calling selector function:ReferenceError: Spry is not defined.
    The only changes I made were adding some text to a few pages and adding metadata info to each page and when viewing the exported HTML locally (prior to uploading) it all behaves as it should...no error messages.
    Any ideas why its doing this? or more importantly, any suggestions on how to stop it from doing this? It wasn't doing this yesterday prior to me making these small changes.
    Here's the URL: www.gardensbytheseaursery.com
    Thanks in advance.
    Jake

    This error would occur if not all the files for the site we're uploaded.
    The 2.0 update includes numerous improvements in the generated HTML, CSS and JavaScript, so while you may have directly changed only certain pages, if you're using an external FTP client all the exported files and folders need to be uploaded. (The new built-in FTP support automatically only generates and uploads files that have changed since the previous upload.)

  • Premiere Pro & After Effects close after a few seconds after the startup?

    Hi,
    I bought Creative Cloud yesterday and everything installed just fine. I haven't tried all Apps yet, but so far Premiere Pro and After Effects close after a few seconds after the startup. There is no dialogue or error window of any kind, the programs just shut down automatically.
    The weird thing is that I had the trial before, but also uninstalled it, but then the apps worked just fine.
    I searched the forum but couldn't find anyone with the exact same issue. I hope someone can help me out.
    My notebook specs:
    Windows 7 Home Premium 64-bit
    Intel Core i7-3610QM
    CPU 2.30 GHz
    RAM 6 GB
    Graphics card: nVidia Geforce GT 630M - 2 GB

    >assigning my nVidia card as the main driver for Premiere Pro (instead of the standard card)
    You MAY need to turn off the onboard graphics "chip" in BIOS
    -http://helpx.adobe.com/premiere-pro/kb/error---preludevideo-play-modules.html
    -http://forums.adobe.com/thread/1001579
    -Use BIOS http://forums.adobe.com/thread/1019004?tstart=0
    -link to why http://forums.adobe.com/message/4685328
    -http://www.anandtech.com/show/4839/mobile-gpu-faceoff-amd-dynamic-switchable-graphics-vs-n vidia-optimus-technology/2

  • Pop-up blocker is turned on..pop-ups still come up...if they have sound it will continue even after i close window...how do i shut this off...don't have this prob with explorer

    my pop-up blocker is turned on..pop-ups still come up..if they have sound it will continue after i close the window..explorer windows pop-up also but sound shuts off when window is closed
    == This happened ==
    Every time Firefox opened
    == since i downloaded firefox

    See [[Pop-up blocker]] for troubleshooting information on why pop-ups are not being blocked. A pop-up from Firefox will have the Firefox logo and it will say Mozilla Firefox on top (See [https://support.mozilla.com/en-US/kb/Pop-up+blocker?bl=n&s=pop%2520up%2520blocker#Is_the_pop_up_coming_from_Firefox_ Is the pop-up coming from Firefox?] for more information.) Attached is an example. If you determine the pop-ups are not coming from Firefox:
    Your issue may be caused by Malware. You can run and update the following '''free''' antivirus software:
    1. Malwarebytes (Free version) - http://www.malwarebytes.org
    2. Spybot Search & Destroy - http://www.safer-networking.org
    3.Spyware Terminator - http://www.spywareterminator.com
    In addition, there are a number of forums you can use to help get rid of your infection. These include:
    *[http://www.bleepingcomputer.com/forums/ Bleeping Computer]
    *[http://forums.spybot.info/ Safer-Networking Forums]
    *[http://www.spywarewarrior.com/index.php Spyware Warrior Forums]
    *[http://www.spywarewarrior.com/index.php SpywareInfo Forums]

  • When a contact tries to call me on FaceTime, they are told I'm not available. In settings, it's turned on and I can call them with no problem immediately after they've tried calling me. Any ideas?

    Facetime tells my contacts I'm not available. My FaceTime is turned on in settings and  I'm able to FaceTime them immediately after they've tried calling me. Any ideas what I'm missing? 

    Try going to settings and turning FaceTime off, then back on again.  A hard reset may also help(hold down the power button and the home button together until you see the Apple logo)

  • Facetime says connecting after you answer the call but doesn't actually connect and both iphone 5s were quick reset-ted and facetime was turnt on and off, any reasons like why or how and how to fix this concerning issue

    facetime says connecting after you answer the call but doesn't actually connect and both iphone 5s were quick reset-ted and facetime was turnt on and off, any reasons like why or how and how to fix this concerning issue

    Apple has released a document which is reported to address the recent FaceTime issue.
    http://support.apple.com/kb/TS5419

  • I got this warning when i open a specific page on my website in IE : MuseJSAssert: Error calling selector function:Error: A security problem occurred.

    Hi,
    I found out when i'm in IE and go to the page 'Artists'
    and i click on a name, for example: 'Abel Equipe ELA/I Gomes'
    I get this warning :
    MuseJSAssert: Error calling selector function:Error: A security problem occurred.
    This is only in IE, not when i use Safari or Chrome
    this is the website link
    Any ideas how to solve this problem?

    There's an invalid hyperlink on the Abel Equipe ELA/I Gomes page on a bit of text that reads "with your input." You need to find this text within Muse, clear the hyperlink and enter a valid one.

  • After I close Firefox and then return to open it my computer says that it is still running and needs to be closed or the system restarted. How do I resolve this?

    Question
    After I close Firefox and then return to open it my computer says that it is still running and needs to be closed or the system restarted. How do I resolve this? edit

    See this - [https://support.mozilla.com/en-US/kb/Firefox%20hangs#w_firefox-hangs-when-you-quit-it Firefox hangs when you close it]

Maybe you are looking for