Esempio n. 1
0
static void WINAPI control_thread( DWORD action)
{
/**************************************
 *
 *	c o n t r o l _ t h r e a d
 *
 **************************************
 *
 * Functional description
 *	Process a service control request.
 *
 **************************************/
	const DWORD state = SERVICE_RUNNING;

	switch (action)
	{
	case SERVICE_CONTROL_STOP:
	case SERVICE_CONTROL_SHUTDOWN:
		report_status(SERVICE_STOP_PENDING, NO_ERROR, 1, 3000);
		SetEvent(stop_event_handle);
		return;

	case SERVICE_CONTROL_INTERROGATE:
		break;

	default:
		break;
	}

	report_status(state, NO_ERROR, 0, 0);
}
Esempio n. 2
0
/*
 * check_data_dir()
 *
 *	This function validates the given cluster directory - we search for a
 *	small set of subdirectories that we expect to find in a valid $PGDATA
 *	directory.	If any of the subdirectories are missing (or secured against
 *	us) we display an error message and exit()
 *
 */
static void
check_data_dir(const char *pg_data)
{
	char		subDirName[MAXPGPATH];
	int			subdirnum;

	/* start check with top-most directory */
	const char *requiredSubdirs[] = {"", "base", "global", "pg_clog",
		"pg_multixact", "pg_subtrans", "pg_tblspc", "pg_twophase",
	"pg_xlog"};

	for (subdirnum = 0;
		 subdirnum < sizeof(requiredSubdirs) / sizeof(requiredSubdirs[0]);
		 ++subdirnum)
	{
		struct stat statBuf;

		snprintf(subDirName, sizeof(subDirName), "%s%s%s", pg_data,
		/* Win32 can't stat() a directory with a trailing slash. */
				 *requiredSubdirs[subdirnum] ? "/" : "",
				 requiredSubdirs[subdirnum]);

		if (stat(subDirName, &statBuf) != 0)
			report_status(PG_FATAL, "check for \"%s\" failed: %s\n",
						  subDirName, getErrorText(errno));
		else if (!S_ISDIR(statBuf.st_mode))
			report_status(PG_FATAL, "%s is not a directory\n",
						  subDirName);
	}
}
Esempio n. 3
0
/*
 * check_data_dir()
 *
 *	This function validates the given cluster directory - we search for a
 *	small set of subdirectories that we expect to find in a valid $PGDATA
 *	directory.	If any of the subdirectories are missing (or secured against
 *	us) we display an error message and exit()
 *
 */
static void
check_data_dir(const char *pg_data)
{
	char		subDirName[MAXPGPATH];
	int			subdirnum;
	const char *requiredSubdirs[] = {"base", "global", "pg_clog",
		"pg_multixact", "pg_subtrans", "pg_tblspc", "pg_twophase",
	"pg_xlog"};

	for (subdirnum = 0;
		 subdirnum < sizeof(requiredSubdirs) / sizeof(requiredSubdirs[0]);
		 ++subdirnum)
	{
		struct stat statBuf;

		snprintf(subDirName, sizeof(subDirName), "%s/%s", pg_data,
				 requiredSubdirs[subdirnum]);

		if (stat(subDirName, &statBuf) != 0)
			report_status(PG_FATAL, "check for %s failed:  %s\n",
						  requiredSubdirs[subdirnum], getErrorText(errno));
		else if (!S_ISDIR(statBuf.st_mode))
			report_status(PG_FATAL, "%s is not a directory\n",
						  requiredSubdirs[subdirnum]);
	}
}
Esempio n. 4
0
void WINAPI CNTL_main_thread( DWORD /*argc*/, char* /*argv*/[])
{
/**************************************
 *
 *	C N T L _ m a i n _ t h r e a d
 *
 **************************************
 *
 * Functional description
 *
 **************************************/
	service_handle =
		RegisterServiceCtrlHandler(service_name->c_str(), control_thread);
	if (!service_handle)
		return;

	// start everything, and wait here for ever, or at
	// least until we get the stop event indicating that
	// the service is stoping.

	bool failure = true;
	DWORD temp = 0;
	if (report_status(SERVICE_START_PENDING, NO_ERROR, 1, 3000) &&
		(stop_event_handle = CreateEvent(NULL, TRUE, FALSE, NULL)) != NULL &&
		report_status(SERVICE_START_PENDING, NO_ERROR, 2, 3000) &&
		!gds__thread_start(main_handler, NULL, 0, 0, 0) &&
		report_status(SERVICE_RUNNING, NO_ERROR, 0, 0))
	{
		failure = false;
		temp = WaitForSingleObject(stop_event_handle, INFINITE);
	}

	DWORD last_error = 0;
	if (failure || temp == WAIT_FAILED)
		last_error = GetLastError();

	if (stop_event_handle)
		CloseHandle(stop_event_handle);

	// Once we are stopped, we will tell the server to
	// do the same.  We could not do this in the control_thread
	// since the Services Control Manager is single threaded,
	// and thus can only process one request at the time.
	SERVICE_STATUS status_info;
	SC_HANDLE hScManager = 0, hService = 0;
	hScManager =
		OpenSCManager(NULL, NULL, GENERIC_READ);
	hService = OpenService(hScManager, remote_name->c_str(),
		GENERIC_READ | GENERIC_EXECUTE);
	ControlService(hService, SERVICE_CONTROL_STOP, &status_info);
	CloseServiceHandle(hScManager);
	CloseServiceHandle(hService);

	report_status(SERVICE_STOPPED, last_error, 0, 0);
}
Esempio n. 5
0
void
TAO_NT_Notify_Service::handle_control (DWORD control_code)
{
  if (control_code == SERVICE_CONTROL_SHUTDOWN
      || control_code == SERVICE_CONTROL_STOP)
    {
      report_status (SERVICE_STOP_PENDING);
      TAO_ORB_Core_instance ()->reactor ()->end_reactor_event_loop ();
      TAO_ORB_Core_instance ()->orb ()->shutdown (1);
      report_status (SERVICE_STOPPED);
    }
  else
    ACE_NT_Service::handle_control (control_code);
}
Esempio n. 6
0
/**
 * We do almost the same thing as we do in run_standalone () except that
 * we update the report_status after init.
 */
int
Activator_NT_Service::svc (void)
{
  ImR_Activator_i server;
  Activator_Options opts;

  if (opts.init_from_registry() != 0)
    {
      report_status (SERVICE_STOPPED);
      return -1;
    }

  try
    {
      int status = server.init (opts);

      if (status == -1)
        {
          report_status (SERVICE_STOPPED);
          return -1;
        }
      else
        {
          report_status (SERVICE_RUNNING);
          server.run ();

          status = server.fini ();

          report_status (SERVICE_STOPPED);

        }
        if (status != -1)
            return 0;
    }
  catch (const CORBA::SystemException& sysex)
    {
      sysex._tao_print_exception (IMR_ACTIVATOR_DISPLAY_NAME);
    }
  catch (const CORBA::UserException& userex)
    {
      userex._tao_print_exception (IMR_ACTIVATOR_DISPLAY_NAME);
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception (IMR_ACTIVATOR_DISPLAY_NAME);
    }

  report_status (SERVICE_STOPPED);
  return -1;
}
Esempio n. 7
0
void WINAPI CNTL_main_thread( DWORD /*argc*/, char* /*argv*/[])
{
/**************************************
 *
 *	C N T L _ m a i n _ t h r e a d
 *
 **************************************
 *
 * Functional description
 *
 **************************************/
	service_handle = RegisterServiceCtrlHandler(service_name->c_str(), control_thread);
	if (!service_handle)
		return;

	int status = 1;
	DWORD temp = 0;

	if (report_status(SERVICE_START_PENDING, NO_ERROR, 1, 3000) &&
		(stop_event_handle = CreateEvent(NULL, TRUE, FALSE, NULL)) != NULL &&
		report_status(SERVICE_START_PENDING, NO_ERROR, 2, 3000))
	{
		try
		{
			Thread::start(main_handler, NULL, THREAD_medium);
			if (report_status(SERVICE_RUNNING, NO_ERROR, 0, 0))
			{
				status = 0;
				temp = WaitForSingleObject(stop_event_handle, INFINITE);
			}
		}
		catch (const Firebird::Exception& ex)
		{
			iscLogException("CNTL: cannot start service handler thread", ex);
		}
	}

	DWORD last_error = 0;
	if (temp == WAIT_FAILED || status)
		last_error = GetLastError();

	if (stop_event_handle)
		CloseHandle(stop_event_handle);

	report_status(SERVICE_STOP_PENDING, NO_ERROR, 1, SHUTDOWN_TIMEOUT);

	fb_shutdown(SHUTDOWN_TIMEOUT, fb_shutrsn_svc_stopped);

	report_status(SERVICE_STOPPED, last_error, 0, 0);
}
Esempio n. 8
0
void
check_ok(migratorContext *ctx)
{
	/* all seems well */
	report_status(ctx, PG_REPORT, "ok");
	fflush(stdout);
}
Esempio n. 9
0
void
check_ok(void)
{
	/* all seems well */
	report_status(PG_REPORT, "ok");
	fflush(stdout);
}
Esempio n. 10
0
int wilson_invert_field_wqs( /* Return value is number of iterations taken */
    wilson_quark_source *wqs, /* source parameters */
    int (*source_func_field)(wilson_vector *src, 
			      wilson_quark_source *wqs),  /* source function */
    wilson_vector *dest,  /* type wilson_vector (answer and initial guess) */
    int (*invert_func_field)(wilson_vector *src, wilson_vector *dest,
			     quark_invert_control *qic, void *dcp),
    quark_invert_control *qic, /* inverter control */
    void *dmp              /* Passthrough Dirac matrix parameters */
    )
{
  int tot_iters;
  wilson_vector *src;

  /* Make the source */
  /* PAD may be used to avoid cache trashing */
#define PAD 0
  src = (wilson_vector *) malloc((sites_on_node+PAD)*sizeof(wilson_vector));
  if(src == NULL){
    printf("wilson_invert_field_wqs(%d): Can't allocate src\n",this_node);
    terminate(1);
  }
  if(source_func_field(src,wqs)){
    printf("wilson_invert_field_wqs(%d): error getting source\n",this_node);
    terminate(1);
  };

  /* Do the inversion */
  tot_iters = invert_func_field(src,dest,qic,dmp);

  report_status(qic);

  free(src);
  return tot_iters;
} /* wilson_invert_field_wqs */
Esempio n. 11
0
/** wait for unbound-anchor process to finish */
static void
waitforubanchor(PROCESS_INFORMATION* pinfo)
{
	/* we have 5 seconds scheduled for it, usually it will be very fast,
	 * with only a UDP message or two (100 msec or so), but the https
	 * connections could take some time */
	DWORD count = 7900;
	DWORD ret = WAIT_TIMEOUT;
	/* decrease timer every 1/10 second, we are still starting up */
	while(ret == WAIT_TIMEOUT) {
		ret = WaitForSingleObject(pinfo->hProcess, 100);
		if(count > 4000) count -= 100;
		else count--; /* go slow, it is taking long */
		if(count > 3000)
			report_status(SERVICE_START_PENDING, NO_ERROR, count);
	}
	verbose(VERB_ALGO, "unbound-anchor done");
	if(ret != WAIT_OBJECT_0) {
		return; /* did not end successfully */
	}
	if(!GetExitCodeProcess(pinfo->hProcess, &ret)) {
		log_err("GetExitCodeProcess failed");
		return;
	}
	verbose(VERB_ALGO, "unbound-anchor exit code is %d", (int)ret);
	if(ret != 0) {
		log_info("The root trust anchor has been updated.");
	}
}
Esempio n. 12
0
bool handle_report()
{
  tm_p current = now();
  checkin_status(db_handler, current, NULL, NULL);
  printf("####################\n");
  report_status();
  return true;
}
Esempio n. 13
0
/**
 * Service control handler. Called by serviceControlManager when a control
 * code is sent to the service (with ControlService).
 * @param ctrl: control code
 */
static void 
hdlr(DWORD ctrl)
{
	if(ctrl == SERVICE_CONTROL_STOP) {
		report_status(SERVICE_STOP_PENDING, NO_ERROR, 0);
		service_stop_shutdown = 1;
		/* send signal to stop */
		if(!WSASetEvent(service_stop_event))
			log_err("Could not WSASetEvent: %s",
				wsa_strerror(WSAGetLastError()));
		return;
	} else {
		/* ctrl == SERVICE_CONTROL_INTERROGATE or whatever */
		/* update status */
		report_status(service_status.dwCurrentState, NO_ERROR, 0);
	}
}
Esempio n. 14
0
void xc::xsim::main()
{
  while (true) {
    XsiStatus status = xsi_clock(instance);
    report_status(status);
    wait();

    std::vector<package *>::iterator pkg;


    for (pkg = packages.begin();pkg != packages.end();pkg++) {
      std::map<std::string, sc_inout_resolved *>::iterator it;
      const char *pkg_name = ((*pkg)->id).c_str();
      for (it = (*pkg)->pins.begin(); it != (*pkg)->pins.end(); it++) {
        sc_inout_resolved *p = (it->second);

        const char *pin_name = (it->first).c_str();
        unsigned int is_driving;
        report_status(xsi_is_pin_driving(instance,
                                         pkg_name,
                                         pin_name,
                                         &is_driving));
        if (is_driving) {
          unsigned int value;
          report_status(xsi_sample_pin(instance,
                                       pkg_name,
                                       pin_name,
                                       &value));
          (*p)->write(sc_logic((int) value));
        }
        else {
          sc_logic bit = (*p)->read();
          if (bit != 'z' && bit != 'x') {
            report_status(xsi_drive_pin(instance,
                                        pkg_name,
                                        pin_name,
                                        bit.to_bool()));
          }
        }
      }

    }

  }
}
Esempio n. 15
0
/*
 * check_single_dir()
 *
 *  Check for the presence of a single directory in PGDATA, and fail if
 * is it missing or not accessible.
 */
static void
check_single_dir(const char *pg_data, const char *subdir)
{
	struct stat statBuf;
	char		subDirName[MAXPGPATH];

	snprintf(subDirName, sizeof(subDirName), "%s%s%s", pg_data,
			 /* Win32 can't stat() a directory with a trailing slash. */
			 *subdir ? "/" : "",
			 subdir);

	if (stat(subDirName, &statBuf) != 0)
		report_status(PG_FATAL, "check for \"%s\" failed: %s\n",
					  subDirName, strerror(errno));
	else if (!S_ISDIR(statBuf.st_mode))
		report_status(PG_FATAL, "%s is not a directory\n",
					  subDirName);
}
Esempio n. 16
0
static void WINAPI control_thread( DWORD action)
{
/**************************************
 *
 *	c o n t r o l _ t h r e a d
 *
 **************************************
 *
 * Functional description
 *	Process a service control request.
 *
 **************************************/
	const DWORD state = SERVICE_RUNNING;

	switch (action)
	{
	case SERVICE_CONTROL_STOP:
	case SERVICE_CONTROL_SHUTDOWN:
		report_status(SERVICE_STOP_PENDING, NO_ERROR, 1, 3000);
		if (hMutex)
			ReleaseMutex(hMutex);
		SetEvent(stop_event_handle);
		return;

	case SERVICE_CONTROL_INTERROGATE:
		break;

	case SERVICE_CREATE_GUARDIAN_MUTEX:
		hMutex = OpenMutex(SYNCHRONIZE, FALSE, mutex_name->c_str());
		if (hMutex)
		{
			UINT error_mode = SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX |
				SEM_NOOPENFILEERRORBOX | SEM_NOALIGNMENTFAULTEXCEPT;
			SetErrorMode(error_mode);
			WaitForSingleObject(hMutex, INFINITE);
		}
		break;

	default:
		break;
	}

	report_status(state, NO_ERROR, 0, 0);
}
Esempio n. 17
0
/// The thread main function.
void InputChannelSender::operator()()
{
    try {

        connect();
        while (connected_ != compute_hostnames_.size()) {
            poll_cm_events();
        }

        data_source_.proceed();
        time_begin_ = std::chrono::high_resolution_clock::now();

        uint64_t timeslice = 0;
        sync_buffer_positions();
        sync_data_source(true);
        report_status();
        while (timeslice < max_timeslice_number_ && !abort_) {
            if (try_send_timeslice(timeslice)) {
                timeslice++;
            }
            poll_completion();
            data_source_.proceed();
            scheduler_.timer();
        }

        // wait for pending send completions
        while (acked_desc_ < timeslice_size_ * timeslice + start_index_desc_) {
            poll_completion();
            scheduler_.timer();
        }
        sync_data_source(false);

        for (auto& c : conn_) {
            c->finalize(abort_);
        }

        L_(debug) << "[i" << input_index_ << "] "
                  << "SENDER loop done";

        while (!all_done_) {
            poll_completion();
            scheduler_.timer();
        }

        time_end_ = std::chrono::high_resolution_clock::now();

        disconnect();
        while (connected_ != 0) {
            poll_cm_events();
        }

        summary();
    } catch (std::exception& e) {
        L_(error) << "exception in InputChannelSender: " << e.what();
    }
}
Esempio n. 18
0
// Do a multimass CG followed by calls to individual CG's
// to finish off.
static int ks_multicg_hybrid_field(	/* Return value is number of iterations taken */
    su3_vector *src,	/* source vector (type su3_vector) */
    su3_vector **psim,	/* solution vectors */
    ks_param *ksp,	/* the offsets */
    int num_offsets,	/* number of offsets */
    quark_invert_control qic[],
    imp_ferm_links_t *fn_multi[]    /* Storage for fermion links */
    )
{
  int i,multi_iters=0,iters=0;

#if defined(HALF_MIXED) && !defined(USE_CG_GPU)
  /* Do multicg in single precision.  (The GPU routine does this automatically for HALF_MIXED) */
  int prec_save = qic[0].prec;
  qic[0].prec = 1;

  Real resid_save = qic[0].resid;
  Real relresid_save =  qic[0].relresid;

  Real single_prec_resid = 1e-6; 
  Real single_prec_relresid = 1e-4;

  if ( resid_save !=0 && resid_save < single_prec_resid)
                    qic[0].resid = single_prec_resid;

  if ( relresid_save != 0 && relresid_save < single_prec_relresid)
                      qic[0].relresid = single_prec_relresid;
  //  node0_printf("Using HALF-MIXED CG; resid = %e\n", qic[0].resid);
#endif
  
  /* First we invert as though all masses took the same Naik epsilon */
  multi_iters = iters = 
    ks_multicg_offset_field( src, psim, ksp, num_offsets, qic, fn_multi[0]);
  report_status(qic+0);

#if defined(HALF_MIXED) && !defined(USE_CG_GPU)
  qic[0].prec = prec_save;
  qic[0].resid = resid_save;
  qic[0].relresid = relresid_save;
#endif

  /* Then we refine using the correct Naik epsilon */
  for(i=0;i<num_offsets;i++){
#ifdef NO_REFINE
    if(fn_multi[i] == fn_multi[0])
      continue;
#endif
    ks_congrad_field_cpu( src, psim[i], qic+i, 0.5*sqrt(ksp[i].offset), fn_multi[i] );
    iters += qic[i].final_iters;
    qic[i].final_iters += multi_iters;
  }

  return iters;
}
Esempio n. 19
0
File: git.c Progetto: drobin/grs
static int git_receive_pack(buffer_t in_buf, buffer_t out_buf,
                            buffer_t err_buf, void* payload) {
  struct git_receive_pack_data* data = (struct git_receive_pack_data*)payload;
  int result;

  if (buffer_get_size(out_buf) > 0 || buffer_get_size(err_buf) > 0) {
    // You still have pending write-data, wait until everything is written back
    // to the client
    return 1;
  }

  do {
    switch (data->current_process) {
    case p_receive_pack_reference_discovery:
      log_debug("reference discovery on %s", data->repository);
      result = reference_discovery(data->repository, process_receive_pack,
                                   out_buf, err_buf,
                                   libgit2_reference_discovery_cb);
      break;
    case p_receive_pack_update_request:
      log_debug("update request on %s", data->repository);
      result = update_request(data->repository, in_buf);
      break;
    case p_receive_pack_report_status:
      log_debug("report status on %s", data->repository);
      result = report_status(data->repository, out_buf);
      break;
    default:
      log_err("Unsupported process requested: %i", data->current_process);
      result = -1;
      break;
    }

    if (result == 0 || result == 3) {
      // Sucess, switch to next sub-process
      data->current_process++;
    }
  } while (result == 3); // result of 3 means, that the next-process should
                         // be executed immediately. Don't wait for new
                         // input-data.

  if (result == 0) { // Success
    if (data->current_process < p_receive_pack_finished) {
      // (Sub-process) finished, but there's at least another pending process.
      result = 1;
    }
  } else if (result == 2) { // Success, but don't execute another sub-process
    data->current_process = p_receive_pack_finished;
    result = 0;
  }

  return result;
}
Esempio n. 20
0
File: udpxy.c Progetto: avble/udpxy
/* process command within a request
 */
static int
process_command( int new_sockfd, struct server_ctx* ctx,
                 const char* param, size_t plen )
{
    int rc = 0;
    const int STAT_OPTIONS = 0;
    const int RESTART_OPTIONS = MSO_SKIP_CLIENTS | MSO_RESTART;

    assert( (new_sockfd > 0) && ctx && param );

    if( 0 == strncmp( ctx->cmd, CMD_UDP, sizeof(ctx->cmd) ) ||
        0 == strncmp( ctx->cmd, CMD_RTP, sizeof(ctx->cmd) ) ) {
        if( ctx->clfree ) {
            rc = udp_relay( new_sockfd, param, plen,
                            &(ctx->mcast_inaddr), ctx );
        }
        else {
            send_http_response( new_sockfd, 401, "Bad request" );
            (void)tmfprintf( g_flog, "Client limit [%d] has been reached.\n",
                    ctx->clmax);
        }
    }
    else if( 0 == strncmp( ctx->cmd, CMD_STATUS, sizeof(ctx->cmd) ) ) {
        rc = report_status( new_sockfd, ctx, STAT_OPTIONS );
    }
    else if( 0 == strncmp( ctx->cmd, CMD_RESTART, sizeof(ctx->cmd) ) ) {
        (void) report_status( new_sockfd, ctx, RESTART_OPTIONS );

        terminate_all_clients( ctx );
        wait_all( ctx );
    }
    else {
        TRACE( (void)tmfprintf( g_flog, "Unrecognized command [%s]"
                    " - ignoring.\n", ctx->cmd) );
        send_http_response( new_sockfd, 401, "Unrecognized request" );
    }

    return rc;
}
Esempio n. 21
0
/**
 * The main function for the service.
 * Called by the services API when starting on windows in background.
 * Arguments could have been present in the string 'path'.
 * @param argc: nr args
 * @param argv: arg text.
 */
static void 
service_main(DWORD ATTR_UNUSED(argc), LPTSTR* ATTR_UNUSED(argv))
{
	struct cfg* cfg = NULL;
	struct svr* svr = NULL;

	service_status_handle = RegisterServiceCtrlHandler(SERVICE_NAME, 
		(LPHANDLER_FUNCTION)hdlr);
	if(!service_status_handle) {
		reportev("Could not RegisterServiceCtrlHandler");
		return;
	}
	
	service_status.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
	service_status.dwServiceSpecificExitCode = 0;

	/* we are now starting up */
	report_status(SERVICE_START_PENDING, NO_ERROR, 3000);
	if(!service_init(&svr, &cfg)) {
		reportev("Could not service_init");
		report_status(SERVICE_STOPPED, NO_ERROR, 0);
		return;
	}

	/* event that gets signalled when we want to quit */
	service_stop_event = WSACreateEvent();
	if(service_stop_event == WSA_INVALID_EVENT) {
		log_err("WSACreateEvent: %s", wsa_strerror(WSAGetLastError()));
		reportev("Could not WSACreateEvent");
		report_status(SERVICE_STOPPED, NO_ERROR, 0);
		return;
	}
	if(!WSAResetEvent(service_stop_event)) {
		log_err("WSAResetEvent: %s", wsa_strerror(WSAGetLastError()));
	}
	wsvc_setup_worker(svr->base);

	/* SetServiceStatus SERVICE_RUNNING;*/
	report_status(SERVICE_RUNNING, NO_ERROR, 0);
	verbose(VERB_QUERY, "winservice - init complete");
	
	/* register DHCP hook and perform first sweep */
	netlist_start(svr);

	/* daemon performs work */
	svr_service(svr);

	/* exit */
	verbose(VERB_ALGO, "winservice - cleanup.");
	report_status(SERVICE_STOP_PENDING, NO_ERROR, 0);
	netlist_stop();
	wsvc_desetup_worker();
	service_deinit(svr, cfg);
	free(service_cfgfile);
	if(service_stop_event) (void)WSACloseEvent(service_stop_event);
	verbose(VERB_QUERY, "winservice - full stop");
	report_status(SERVICE_STOPPED, NO_ERROR, 0);
}
Esempio n. 22
0
/*
 * check_bin_dir()
 *
 *	This function searches for the executables that we expect to find
 *	in the binaries directory.	If we find that a required executable
 *	is missing (or secured against us), we display an error message and
 *	exit().
 */
static void
check_bin_dir(ClusterInfo *cluster)
{
	struct stat statBuf;

	/* check bindir */
	if (stat(cluster->bindir, &statBuf) != 0)
		report_status(PG_FATAL, "check for \"%s\" failed: %s\n",
					  cluster->bindir, getErrorText(errno));
	else if (!S_ISDIR(statBuf.st_mode))
		report_status(PG_FATAL, "%s is not a directory\n",
					  cluster->bindir);

	validate_exec(cluster->bindir, "postgres");
	validate_exec(cluster->bindir, "pg_ctl");
	validate_exec(cluster->bindir, "pg_resetxlog");
	if (cluster == &new_cluster)
	{
		/* these are only needed in the new cluster */
		validate_exec(cluster->bindir, "psql");
		validate_exec(cluster->bindir, "pg_dumpall");
	}
}
Esempio n. 23
0
void WINAPI
service_main (int argc, char **argv)
{
    /* Register our service control handler:                                 */
    service_status_handle 
        = RegisterServiceCtrlHandler (service_name, service_control);
    if (!service_status_handle)
        return;

    service_status.dwServiceType             = SERVICE_WIN32_OWN_PROCESS;
    service_status.dwServiceSpecificExitCode = 0;

    /* report the status to the service control manager.                     */
    if (report_status (
            SERVICE_START_PENDING,      /*  Service state                    */
            NO_ERROR,                   /*  Exit code                        */
            3000))                      /*  Wait Hint                        */
        service_start (argc, argv);

    /* Try to report the stopped status to the service control manager.      */
    if (service_status_handle)
        report_status (SERVICE_STOPPED, error_code, 0);
}
Esempio n. 24
0
/**
 * Init service. Keeps calling status pending to tell service control
 * manager that this process is not hanging.
 * @param r: restart, true on restart
 * @param d: daemon returned here.
 * @param c: config file returned here.
 * @return false if failed.
 */
static int
service_init(struct svr** d, struct cfg** c)
{
	struct cfg* cfg = NULL;
	struct svr* svr = NULL;

	if(!service_cfgfile) {
		char* newf = lookup_reg_str("Software\\DnssecTrigger", "ConfigFile");
		if(newf) service_cfgfile = newf;
		else 	service_cfgfile = strdup(CONFIGFILE);
		if(!service_cfgfile) fatal_exit("out of memory");
	}

	/* create config */
	cfg = cfg_create(service_cfgfile);
	if(!cfg) return 0;
	report_status(SERVICE_START_PENDING, NO_ERROR, 2800);

	/* create daemon */
	svr = svr_create(cfg);
	if(!svr) return 0;
	report_status(SERVICE_START_PENDING, NO_ERROR, 2600);

	verbose(VERB_QUERY, "winservice - apply settings");
	/* apply settings and init */
	verbosity = cfg->verbosity + service_cmdline_verbose;
	log_init(cfg->logfile, cfg->use_syslog, cfg->chroot);
	report_status(SERVICE_START_PENDING, NO_ERROR, 2400);

	hook_resolv_localhost(cfg);
	report_status(SERVICE_START_PENDING, NO_ERROR, 2300);

	*d = svr;
	*c = cfg;
	return 1;
}
Esempio n. 25
0
void KSGService::handle_control(DWORD control_code)
{
	if(SERVICE_CONTROL_STOP == control_code
		|| SERVICE_CONTROL_SHUTDOWN == control_code)
	{
		report_status(SERVICE_STOP_PENDING);
		if(_gateway)
			_gateway->stop();
	}
	else
	{
		
		ACE_NT_Service::handle_control(control_code);
	}
}
Esempio n. 26
0
void ControlInput::update_status(void){
	if(calibrating){
		if(status != STATUS_CALIBRATING){
			status = STATUS_CALIBRATING;
			report_status();
		}
		return;
	}

	//Check that driver status is OK:
	if(control_receiver->get_status() == STATUS_OK){
		if(status != STATUS_NOTOK){
			status = STATUS_OK;
			report_status();
		}
	}else{
		//Status is not OK!..
		//Check for transistion:
		if(status != STATUS_OK){
			status = STATUS_NOTOK;
			report_status();
		}
	};
}
Esempio n. 27
0
xc::xsim::xsim(sc_module_name name,
               std::string xn,
               std::string args) : xsystem(name, xn)
{
  // Create Simulator Instance
  XsiStatus status = xsi_create(&instance, args.c_str());
  report_status(status);

  // SystemC elaboration
  SC_THREAD(main);
  sensitive << clk_in.pos();




}
Esempio n. 28
0
static      u32
emuPIOROM_w(u32 addr, u32 data, u32 num)
{
	if (data) {
		dsr_set_active(&emuPIODSR);

		SET_AREA_HANDLER(0x4000, 0x1000, &dsr_rom_emupio_handler);
		SET_AREA_HANDLER(0x5000, 0x1000, &dsr_rom_emupio_io_handler);

	} else {
		report_status(STATUS_PIO_ACCESS, false);
		dsr_set_active(NULL);
		SET_AREA_HANDLER(0x4000, 0x2000, &zero_memory_handler);
	}
	return 0;
}
Esempio n. 29
0
int KSGService::svc()
{
	// 启动服务
	int ret = -1;
	if(!_gateway)
	{
		_gateway = new KSGateway;
	}
	if(_gateway)
	{
		report_status (SERVICE_RUNNING);
		ret = KsgStartServer(_gateway);
		delete _gateway;
		_gateway = NULL;
	}
	return ret;
}
Esempio n. 30
0
void WINAPI
service_control (DWORD control_code)
{
    /* Handle the requested control code.                                    */
    switch (control_code)
      {
        case SERVICE_CONTROL_STOP:      /*  Stop the service                 */
            service_status.dwCurrentState = SERVICE_STOP_PENDING;
            service_stop ();
            break;

        case SERVICE_CONTROL_INTERROGATE:/* Update the service status        */
            break;
        default:                        /*  Invalid control code             */
            break;
      }
    report_status (service_status.dwCurrentState, NO_ERROR, 0);
}