Пример #1
0
int main(int argc, char **argv)
{
	int retval;
	void *handle = NULL;
	short	http_port = 8081;
	// Binds on IPv4 & IPv6, refer to /proc/sys/net/ipv6/bindv6only
	char	*http_addr = "::";
	struct	evhttp *http_server = NULL;

	cweb_init();
	retval = init_pages();
	if (retval) {
		printf("[ERROR] loading of plugins failed.\n");
		return EXIT_FAILURE;
	}

	event_init();
	http_server = evhttp_start(http_addr, http_port);
	evhttp_set_gencb(http_server, cweb_request_handler, NULL);

	fprintf(stderr, "Server started on port %d\n", http_port);
	event_dispatch();

	return(0);
}
Пример #2
0
void region_init(void)
{
  // VALGRIND_DO_QUICK_LEAK_CHECK;
  // fprintf(stderr, "## region_init\n");
  static int initialized = 0;

  if ( initialized )
    return;

  else
    {
#ifdef STAGGER_RSTART
      rstart = -64; /* Save 64 bytes of memory! (sometimes ;-)) */
#endif
      init_pages();
      permanent = newregion();
      if (getenv("REGIONSTATS"))
	benchmark_init();
#ifdef DEBUG_RALLOC
      atexit(memusage);
#endif
    }
  initialized = 1;
  // VALGRIND_DO_QUICK_LEAK_CHECK;
}
Пример #3
0
/**************************** core implementation ****************************/
int page_sim_init(unsigned page_size, unsigned mem_size,
                  unsigned addr_space_size, unsigned max_concurrent_operations,
                  pagesim_callback callback)
{
    if (!globals.active)
	{
		if (pthread_mutex_lock(&lib_init_end_mutex) == ERROR)
			return ERROR;
        if (check_init_constraints(page_size,
                                   mem_size,
                                   addr_space_size,
                                   max_concurrent_operations) == ERROR)
            return ERROR;
        globals.page_size = page_size;
        globals.mem_size = mem_size;
        globals.addr_space_size = addr_space_size;
        globals.act_concurrent_operations = 0;
		globals.act_queries = 0;
        globals.logger = callback;
        
        if (pthread_mutex_init(&globals.concurrent_operations_mutex, NULL) 
            == ERROR)
            return ERROR;
        if (pthread_cond_init(&globals.io_oveflow_cond, NULL) 
            == ERROR)
            return ERROR;
        if (pthread_mutex_init(&globals.logger_mutex, NULL) 
            == ERROR)
            return ERROR;
        if (pthread_mutex_init(&globals.select_mutex, NULL) 
            == ERROR)
            return ERROR;
		if (pthread_mutex_init(&globals.act_queries_mutex, NULL) 
            == ERROR)
            return ERROR;
        init_strategy_metadata();
        if (init_swap() == ERROR)
            return ERROR;
        if (init_pages() == ERROR)
            return ERROR;
        
        globals.active = true;
		if (pthread_mutex_unlock(&lib_init_end_mutex) == ERROR)
			return ERROR;
		return SUCCESS;
    }
    return ERROR;
}
Пример #4
0
int main(int argc, char *argv[])
{
	int retval;
	void *handle = NULL;

	cweb_init();
	cmdline_args(argc, argv);

	retval = init_pages();	/* load pages */
	if (retval) {
		printf("[ERROR] loading of pages failed.\n");
		return EXIT_FAILURE;
	}

	struct page *cur_page = pages_list;
	while (cur_page != NULL) {
		cur_page->check_support(&sys_info);
		cur_page = cur_page->next;
	}
	return EXIT_SUCCESS;
}
Пример #5
0
int main(void)
{
  ProtoMsg msg;
  msg.type = -1;
  msg.msgLen = 0;
  size_t i = 0;

  init_pages();

  do 
  {
    recvMsg(IN, &msg, sizeof(msg));

    switch (msg.type)
    {
      case (PROTO_GET):
      {
        if (msg.msgLen == 0)
        {
          i = 0;
        }
        else
        {
          //this could overflow if msgLen is > PAGE_SIZE
          // this is counting on the router to make sure it doesn't happen . . .
          recvMsg(IN, gBuf, msg.msgLen);
          gBuf[msg.msgLen] = '\0';
          i = findPage((char*)gBuf);  
        }

        msg.type = PROTO_GET_ACK;

        if (i >= MAX_LINKS)
        {
#ifdef PATCHED
          msg.msgLen = snprintf(gOutBuf, PAGE_SIZE, "#s : #s", (char*)gBuf, gPageNotFoundError);
#else
          msg.msgLen = snprintf(gOutBuf, PAGE_SIZE, (char*)gBuf);
          msg.msgLen += snprintf(gOutBuf + msg.msgLen, PAGE_SIZE - msg.msgLen, " : #s", gPageNotFoundError);
#endif 
          sendMsg(OUT, &msg, sizeof(msg));
          sendMsg(OUT, gOutBuf, msg.msgLen);
        }
        else
        {
          msg.msgLen = gPages[i].len;
          sendMsg(OUT, &msg, sizeof(msg));
          sendMsg(OUT, gPages[i].data, msg.msgLen);
        }

        break;
      }
      case (PROTO_BYE):
      {
        return (0);
      }
      default:
      {
        msg.type = PROTO_ERROR;
        msg.msgLen = 0;
        break;
      }
    }
  } while (1);

  return (-1);
}
Пример #6
0
FrontEnd::FrontEnd(wxWindow* parent, int id, const wxString& title):
    wxFrame(parent, id, title)//, pos, size, wxDEFAULT_FRAME_STYLE)
{
    //_CrtSetBreakAlloc(3446);
    //_CrtSetDbgFlag(_CRTDBG_CHECK_ALWAYS_DF);
    ////////////////////////////////////////////////////
    // books creation
    m_panel    = NULL;
    m_bookCtrl = NULL;

    //// create a dummy image list with a few icons
    //const wxSize imageSize(32, 32);

    //m_imageList = new wxImageList(imageSize.GetWidth(), imageSize.GetHeight());
    //m_imageList->
    //    Add(wxArtProvider::GetIcon(wxART_INFORMATION, wxART_OTHER, imageSize));
    //m_imageList->
    //    Add(wxArtProvider::GetIcon(wxART_QUESTION, wxART_OTHER, imageSize));
    //m_imageList->
    //    Add(wxArtProvider::GetIcon(wxART_WARNING, wxART_OTHER, imageSize));
    //m_imageList->
    //    Add(wxArtProvider::GetIcon(wxART_ERROR, wxART_OTHER, imageSize));

    // Panel
    m_panel = new wxPanel(this);

    // Set sizers
    m_sizerFrame = new wxBoxSizer(wxVERTICAL);

    // Create list book
    int flags;
    flags = wxBK_LEFT;
    m_bookCtrl = new wxListbook(m_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, flags);
    wxListView* list = ((wxListbook*)m_bookCtrl)->GetListView();
    list->SetColumnWidth(0, 140);

    if ( !m_bookCtrl )
        assert(0);
    m_bookCtrl->Hide();

    //m_bookCtrl->SetImageList(m_imageList);

    init_pages(m_bookCtrl);

    m_sizerFrame->Add(m_bookCtrl, wxSizerFlags(5).Expand().Border());
    //m_sizerFrame->Insert(0, m_bookCtrl, wxSizerFlags(15).Expand().Border());
    
    m_sizerFrame->Show(m_bookCtrl);
    m_sizerFrame->Layout();
    ////////////////////////////////////////////////////

    m_btnNextSong = new wxButton(m_panel, ID_NEXT_SONG, "Next Song");
    m_sizerFrame->Add(m_btnNextSong, wxSizerFlags(1).Expand());

    m_panel->SetSizer(m_sizerFrame);
    
    m_sizerFrame->SetSizeHints(this);

    InitMenus();
    InitProperties();    

    if(!DBConnect("KTVAdmin", "admin", "localhost", "ktv"))
        wxMessageBox("Cannot connect to the database£¡", "Error");
}