Changeset 436


Ignore:
Timestamp:
Oct 15, 2014, 10:44:36 AM (11 years ago)
Author:
dmik
Message:

icedtea-web: Use unnamed pipe instead of unix-style named pipe for debug console.

Similar to r368.

Location:
trunk/icedtea-web
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/icedtea-web/netx/net/sourceforge/jnlp/util/logging/JavaConsole.java

    r427 r436  
    5151import java.io.File;
    5252import java.io.FileInputStream;
     53import java.io.InputStream;
    5354import java.io.InputStreamReader;
    5455import java.nio.charset.Charset;
     
    535536    }
    536537
    537     public void createPluginReader(final File file) {
    538         OutputController.getLogger().log("Starting processing of plugin-debug-to-console " + file.getAbsolutePath());
     538    public void createPluginReader(final InputStream inputstream) {
     539        OutputController.getLogger().log("Starting processing of plugin-debug-to-console " + inputstream);
    539540        Thread t = new Thread(new Runnable() {
    540541
    541542            @Override
    542543            public void run() {
     544                OutputController.getLogger().log("Started processing of plugin-debug-to-console " + inputstream);
    543545                BufferedReader br = null;
    544546                try {
    545                     br = new BufferedReader(new InputStreamReader(new FileInputStream(file),
     547                    br = new BufferedReader(new InputStreamReader(inputstream,
    546548                            Charset.forName("UTF-8")));
    547549                    //never ending loop
     
    567569                    }
    568570                }
    569                 OutputController.getLogger().log("Ended processing of plugin-debug-to-console " + file.getAbsolutePath());
     571                OutputController.getLogger().log("Ended processing of plugin-debug-to-console " + inputstream);
    570572            }
    571573        }, "plugin-debug-to-console reader thread");
    572574        t.setDaemon(true);
    573575        t.start();
    574 
    575         OutputController.getLogger().log("Started processing of plugin-debug-to-console " + file.getAbsolutePath());
     576    }
     577
     578    public void createPluginReader(final File file) {
     579        OutputController.getLogger().log("Starting processing of plugin-debug-to-console " + file.getAbsolutePath());
     580        try {
     581            createPluginReader(new FileInputStream(file));
     582        } catch (Exception ex) {
     583            OutputController.getLogger().log(ex);
     584        }
    576585    }
    577586}
  • trunk/icedtea-web/plugin/icedteanp/IcedTeaNPPlugin.cc

    r433 r436  
    173173#endif
    174174
     175#ifdef __OS2__
     176int debug_pipe[2] = { -1 };
     177#else
    175178// Applet viewer debug pipe name.
    176179gchar* debug_pipe_name = NULL;
     180#endif
    177181
    178182// Applet viewer output watch source.
     
    588592  initialize_debug();//should be already initialized, but...
    589593  if (plugin_debug_to_console){
     594#ifdef __OS2__
     595    if (socketpair (AF_LOCAL, SOCK_STREAM, 0, debug_pipe) == -1)
     596      {
     597        PLUGIN_ERROR ("Failed to create debug pipe", strerror (errno));
     598        np_error = NPERR_GENERIC_ERROR;
     599        goto cleanup_debug_pipe;
     600      }
     601    PLUGIN_DEBUG ("ITNP_New: created debug fifo: %d/%d\n", debug_pipe [0], debug_pipe [1]);
     602#else
    590603    // debug_pipe_name
    591604    debug_pipe_name = g_strdup_printf ("%s/%d-icedteanp-plugin-debug-to-appletviewer",
     
    610623      }
    611624    PLUGIN_DEBUG ("ITNP_New: created debug fifo: %s\n", debug_pipe_name);
     625#endif
    612626  }
    613627
     
    622636  fcntl (in_pipe [0], F_SETFD, FD_CLOEXEC);
    623637  fcntl (out_pipe [0], F_SETFD, FD_CLOEXEC);
     638  if (plugin_debug_to_console)
     639    fcntl (debug_pipe [0], F_SETFD, FD_CLOEXEC);
    624640#endif
    625641
     
    630646  CLOSE_FD (in_pipe [1]);
    631647  CLOSE_FD (out_pipe [1]);
     648  if (plugin_debug_to_console)
     649    CLOSE_FD (debug_pipe [1]);
    632650#endif
    633651
     
    698716  // debug_to_appletviewer
    699717  if (plugin_debug_to_console){
     718#ifdef __OS2__
     719    debug_to_appletviewer = g_io_channel_unix_new (debug_pipe [0]);
     720#else
    700721    debug_to_appletviewer = g_io_channel_new_file (debug_pipe_name,
    701722                                                 "w", &channel_error);
     723#endif
    702724    if (!debug_to_appletviewer)
    703725      {
     
    754776  out_to_appletviewer = NULL;
    755777
     778#ifdef __OS2__
     779 cleanup_debug_pipe:
     780  if (plugin_debug_to_console){
     781    CLOSE_FD (debug_pipe [0]);
     782    CLOSE_FD (debug_pipe [1]);
     783  }
     784#else
    756785  if (plugin_debug_to_console){
    757786    // cleanup_debug_pipe:
     
    766795    debug_pipe_name = NULL;
    767796  }
    768 
    769 
     797#endif
    770798
    771799  // cleanup_out_pipe:
     
    16361664  command_line.push_back(static_cast<std::ostringstream &>(std::ostringstream() << out_pipe[1]).str());
    16371665  command_line.push_back(static_cast<std::ostringstream &>(std::ostringstream() << in_pipe[1]).str());
     1666  if (plugin_debug_to_console)
     1667    command_line.push_back(static_cast<std::ostringstream &>(std::ostringstream() << debug_pipe[1]).str());
    16381668#else
    16391669  command_line.push_back(out_pipe_name);
    16401670  command_line.push_back(in_pipe_name);
    1641 #endif
    16421671  if (plugin_debug_to_console){
    16431672      command_line.push_back(debug_pipe_name);
    16441673  }
     1674#endif
    16451675
    16461676  // Finished command line parameters
     
    24402470    out_to_appletviewer = NULL;
    24412471    // cleanup_debug_pipe:
     2472#ifdef __OS2__
     2473    CLOSE_FD (debug_pipe [0]);
     2474    CLOSE_FD (debug_pipe [1]);
     2475#else
    24422476    // Delete debug pipe.
    24432477    PLUGIN_DEBUG ("NP_Shutdown: deleting debug fifo: %s\n", debug_pipe_name);
     
    24472481    g_free (debug_pipe_name);
    24482482    debug_pipe_name = NULL;
     2483#endif
    24492484  }
    24502485 
  • trunk/icedtea-web/plugin/icedteanp/IcedTeaNPPlugin.h

    r431 r436  
    134134extern FILE * plugin_file_log;
    135135extern std::string plugin_file_log_name;
     136#ifdef __OS2__
     137extern int debug_pipe[2];
     138#else
    136139extern gchar* debug_pipe_name;
     140#endif
    137141
    138142extern gboolean jvm_up;
  • trunk/icedtea-web/plugin/icedteanp/IcedTeaPluginUtils.cc

    r429 r436  
    12071207        }
    12081208        if (plugin_debug_to_console){
     1209#ifdef __OS2__
     1210          if (debug_pipe[0] != -1){
     1211            PLUGIN_DEBUG("plugin_debug_to_console: true, pipe %d\n", debug_pipe[0]);
     1212          }
     1213#else
    12091214          if (debug_pipe_name){
    12101215            PLUGIN_DEBUG("plugin_debug_to_console: true, pipe %s\n", debug_pipe_name);
     
    12121217            PLUGIN_DEBUG("plugin_debug_to_console: true, pipe not yet known or broken\n");
    12131218          }
     1219#endif
    12141220        } else {
    12151221          PLUGIN_DEBUG("plugin_debug_to_console: false\n");
  • trunk/icedtea-web/plugin/icedteanp/os2/java/sun/applet/PluginMainBase.java

    r431 r436  
    5252    private static int inPipe = -1;
    5353    private static int outPipe = -1;
     54    private static int debugPipe = -1;
    5455
    5556    static boolean checkArgs(String args[]) {
     
    6061                DeploymentConfiguration.move14AndOlderFilesTo15StructureCatched();
    6162                if (JavaConsole.isEnabled()) {
    62                     if ((args.length < 3) || !new File(args[2]).exists()) {
     63                    if ((args.length < 3) || (debugPipe = Integer.valueOf(args[2]).intValue()) < 0) {
    6364                        OutputController.getLogger().log(OutputController.Level.ERROR_ALL, "Warning, although console is on, plugin debug connection do not exists. No plugin information will be displayed in console (only java ones).");
    64                     } else {
    65                         JavaConsole.getConsole().createPluginReader(new File(args[2]));
    6665                    }
    6766                }
     
    8180        fdAccess.set(outPipeFD, outPipe);
    8281        streamHandler = new PluginStreamHandler(new FileInputStream(inPipeFD), new FileOutputStream(outPipeFD));
     82        if (JavaConsole.isEnabled() && debugPipe != -1) {
     83            FileDescriptor debugPipeFD = new FileDescriptor();
     84            fdAccess.set(debugPipeFD, debugPipe);
     85            JavaConsole.getConsole().createPluginReader(new FileInputStream(debugPipeFD));
     86        }
    8387        PluginDebug.debug("Streams initialized");
    8488        return streamHandler;
Note: See TracChangeset for help on using the changeset viewer.