Ejemplo n.º 1
0
/* send these to ceed*/
void return_turff_nodes(int sock_fd)
{
  int i;
  char *tmp_node[KEY_ARR_SZ];

  /* clear the list and read the nodes from the db*/
  get_db_nodes(NULL);
  turff_node *cur = head;

  for (i = 0; i <  KEY_ARR_SZ; i++)
    tmp_node[i] = NULL;

  while (cur != NULL) {
    tmp_node[KEY('d')] = cur->id;

#ifdef DBG
    DEBUG("Sent turff node id : %s ip: %s port %s\n", cur->id, cur->ip, cur->port);
#endif

    send_args(sock_fd, tmp_node);
    cur = cur->next;
  }

  tmp_node[KEY('e')] = "set";
  send_args(sock_fd, tmp_node);
}
Ejemplo n.º 2
0
Archivo: start.c Proyecto: TrTLE/core
SAL_IMPLEMENT_MAIN_WITH_ARGS( argc, argv )
{
    sal_Bool bSentArgs = sal_False;
    const char* pUsePlugin;
    rtl_uString *pPipePath = NULL;
    Args *args;
    int status = 0;
    struct splash* splash = NULL;
    struct sigaction sigpipe_action;
    struct sigaction sigterm_action;

    /* turn SIGPIPE into an error */
    memset(&sigpipe_action, 0, sizeof(struct sigaction));
    sigpipe_action.sa_handler = SIG_IGN;
    sigemptyset(&sigpipe_action.sa_mask);
    sigaction(SIGPIPE, &sigpipe_action, NULL);
    memset(&sigterm_action, 0, sizeof(struct sigaction));
    sigterm_action.sa_handler = &sigterm_handler;
    sigemptyset(&sigterm_action.sa_mask);
    sigaction(SIGTERM, &sigterm_action, NULL);

    args = args_parse ();
    args->pAppPath = get_app_path( argv[0] );
    if ( !args->pAppPath )
    {
        fprintf( stderr, "ERROR: Can't read app link\n" );
        exit( 1 );
    }

#ifndef ENABLE_QUICKSTART_LIBPNG
    /* we can't load and render it anyway */
    args->bInhibitSplash = sal_True;
#endif

    pUsePlugin = getenv( "SAL_USE_VCLPLUGIN" );
    if ( pUsePlugin && !strcmp(pUsePlugin, "svp") )
        args->bInhibitSplash = sal_True;

    if ( !args->bInhibitPipe && getenv("LIBO_XDGAPP") == NULL )
    {
        int fd = 0;
        pPipePath = get_pipe_path( args->pAppPath );

        if ( ( fd = connect_pipe( pPipePath ) ) >= 0 )
        {
            // Wait for answer
            char resp[ strlen( "InternalIPC::SendArguments" ) + 1];
            ssize_t n = read( fd, resp, SAL_N_ELEMENTS( resp ) );
            if (n == (ssize_t) SAL_N_ELEMENTS( resp )
                && (memcmp(
                resp, "InternalIPC::SendArguments",
                SAL_N_ELEMENTS( resp ) - 1) == 0)) {
                rtl_uString *pCwdPath = NULL;
                osl_getProcessWorkingDir( &pCwdPath );

                // Then send args
                bSentArgs = send_args( fd, pCwdPath );
           }

            close( fd );
        }
    }

    if ( !bSentArgs )
    {
        /* we have to prepare for, and exec the binary */
        int nPercent = 0;
        ChildInfo *info;
        sal_Bool bAllArgs = sal_True;
        sal_Bool bShortWait, bRestart;

        /* sanity check pieces */
        system_checks();

        /* load splash image and create window */
        if ( !args->bInhibitSplash )
        {
            splash = splash_create(args->pAppPath, argc, argv);
        }

        /* pagein */
        if (!args->bInhibitPagein)
            exec_pagein (args);

        /* javaldx */
#if HAVE_FEATURE_JAVA
        if (!args->bInhibitJavaLdx)
            exec_javaldx (args);
#endif

        do
        {
            bRestart = sal_False;

            /* fast updates if we have somewhere to update it to */
            bShortWait = splash ? sal_True : sal_False;

            /* Periodically update the splash & the percent according
               to what status_fd says, poll quickly only while starting */
            info = child_spawn (args, bAllArgs, bShortWait);
            g_pProcess = info->child;
            while (!child_exited_wait (info, bShortWait))
            {
                ProgressStatus eResult;

                splash_draw_progress( splash, nPercent );
                eResult = read_percent( info, &nPercent );
                if (eResult != ProgressContinue)
                {
                    splash_destroy(splash);
                    splash = NULL;
                    bShortWait = sal_False;
                }

            }


            status = child_get_exit_code(info);
            g_pProcess = NULL; // reset
            switch (status) {
            case EXITHELPER_CRASH_WITH_RESTART: // re-start with just -env: parameters
                bRestart = sal_True;
                bAllArgs = sal_False;
                break;
            case EXITHELPER_NORMAL_RESTART: // re-start with all arguments
                bRestart = sal_True;
                bAllArgs = sal_True;
                break;
            default:
                break;
            }

            child_info_destroy (info);
        } while (bRestart);
    }

    /* cleanup */
    if ( pPipePath )
        rtl_uString_release( pPipePath );
    args_free (args);

    return status;
}