void
AsyncIoThread::run()
{
  bool first_flag = true;
  Request *request;
  NDB_TICKS last_yield_ticks;

  // Create theMemoryChannel in the thread that will wait for it
  NdbMutex_Lock(theStartMutexPtr);
  theStartFlag = true;
  NdbMutex_Unlock(theStartMutexPtr);
  NdbCondition_Signal(theStartConditionPtr);

  EmulatedJamBuffer jamBuffer;
  jamBuffer.theEmulatedJamIndex = 0;
  // This key is needed by jamNoBlock().
  NdbThread_SetTlsKey(NDB_THREAD_TLS_JAM, &jamBuffer);

  while (1)
  {
    if (m_real_time)
    {
      /**
       * If we are running in real-time we'll simply insert a break every
       * so often to ensure that low-prio threads aren't blocked from the
       * CPU, this is especially important if we're using a compressed
       * file system where lots of CPU is used by this thread.
       */
      bool yield_flag = false;
      const NDB_TICKS current_ticks = NdbTick_getCurrentTicks();

      if (first_flag)
      {
        first_flag = false;
        yield_flag = true;
      }
      else
      {
        Uint64 micros_passed =
          NdbTick_Elapsed(last_yield_ticks, current_ticks).microSec();
        if (micros_passed > 10000)
        {
          yield_flag = true;
        }
      }
      if (yield_flag)
      {
        if (NdbThread_yield_rt(theThreadPtr, TRUE))
        {
          m_real_time = false;
        }
        last_yield_ticks = current_ticks;
      }
    }
    request = theMemoryChannelPtr->readChannel();
    if (!request || request->action == Request::end)
    {
      DEBUG(ndbout_c("Nothing read from Memory Channel in AsyncFile"));
      theStartFlag = false;
      return;
    }//if

    AsyncFile * file = request->file;
    m_current_request= request;
    switch (request->action) {
    case Request::open:
      file->openReq(request);
      if (request->error == 0 && request->m_do_bind)
        attach(file);
      break;
    case Request::close:
      file->closeReq(request);
      detach(file);
      break;
    case Request::closeRemove:
      file->closeReq(request);
      file->removeReq(request);
      detach(file);
      break;
    case Request::readPartial:
    case Request::read:
      file->readReq(request);
      break;
    case Request::readv:
      file->readvReq(request);
      break;
    case Request::write:
      file->writeReq(request);
      break;
    case Request::writev:
      file->writevReq(request);
      break;
    case Request::writeSync:
      file->writeReq(request);
      file->syncReq(request);
      break;
    case Request::writevSync:
      file->writevReq(request);
      file->syncReq(request);
      break;
    case Request::sync:
      file->syncReq(request);
      break;
    case Request::append:
      file->appendReq(request);
      break;
    case Request::append_synch:
      file->appendReq(request);
      file->syncReq(request);
      break;
    case Request::rmrf:
      file->rmrfReq(request, file->theFileName.c_str(),
                    request->par.rmrf.own_directory);
      break;
    case Request::end:
      theStartFlag = false;
      return;
    case Request::allocmem:
    {
      allocMemReq(request);
      break;
    }
    case Request::buildindx:
      buildIndxReq(request);
      break;
    case Request::suspend:
      if (request->par.suspend.milliseconds)
      {
        g_eventLogger->debug("Suspend %s %u ms",
                             file->theFileName.c_str(),
                             request->par.suspend.milliseconds);
        NdbSleep_MilliSleep(request->par.suspend.milliseconds);
        continue;
      }
      else
      {
        g_eventLogger->debug("Suspend %s",
                             file->theFileName.c_str());
        theStartFlag = false;
        return;
      }
    default:
      DEBUG(ndbout_c("Invalid Request"));
      abort();
      break;
    }//switch
    m_last_request = request;
    m_current_request = 0;

    // No need to signal as ndbfs only uses tryRead
    theReportTo->writeChannelNoSignal(request);
    m_fs.wakeup();
  }
}
Example #2
0
QT_BEGIN_NAMESPACE

/*****************************************************************************
  Q3CString member functions
 *****************************************************************************/

/*!
    \class Q3CString
    \reentrant
    \brief The Q3CString class provides an abstraction of the classic C
    zero-terminated char array (char *).

    \compat

    Q3CString tries to behave like a more convenient \c{const char *}.
    The price of doing this is that some algorithms will perform
    badly. For example, append() is O(length()) since it scans for a
    null terminator. Although you might use Q3CString for text that is
    never exposed to the user, for most purposes, and especially for
    user-visible text, you should use QString. QString provides
    implicit sharing, Unicode and other internationalization support,
    and is well optimized.

    Note that for the Q3CString methods that take a \c{const char *}
    parameter the \c{const char *} must either be 0 (null) or not-null
    and '\0' (NUL byte) terminated; otherwise the results are
    undefined.

    A default constructed Q3CString is \e null, i.e. both the length
    and the data pointer are 0 and isNull() returns true.
    
    \note However, if you ask for the data pointer of a null Q3CString
    by calling data(), then because the internal representation of the
    null Q3CString is shared, it will be detached and replaced with a
    non-shared, empty representation, a non-null data pointer will be
    returned, and subsequent calls to isNull() will return false. But
    if you ask for the data pointer of a null Q3CString by calling
    constData(), the shared internal representation is not detached, a
    null data pointer is returned, and subsequent calls to isNull()
    will continue to return true.

    A Q3CString that references the empty string ("", a single '\0'
    char) is \e empty, i.e. isEmpty() returns true.  Both null and
    empty Q3CStrings are legal parameters to the methods.  Assigning
    \c{const char *} 0 to Q3CString produces a null Q3CString.

    The length() function returns the length of the string; resize()
    resizes the string and truncate() truncates the string. A string
    can be filled with a character using fill(). Strings can be left
    or right padded with characters using leftJustify() and
    rightJustify(). Characters, strings and regular expressions can be
    searched for using find() and findRev(), and counted using
    contains().

    Strings and characters can be inserted with insert() and appended
    with append(). A string can be prepended with prepend().
    Characters can be removed from the string with remove() and
    replaced with replace().

    Portions of a string can be extracted using left(), right() and
    mid(). Whitespace can be removed using stripWhiteSpace() and
    simplifyWhiteSpace(). Strings can be converted to uppercase or
    lowercase with upper() and lower() respectively.

    Strings that contain numbers can be converted to numbers with
    toShort(), toInt(), toLong(), toULong(), toFloat() and toDouble().
    Numbers can be converted to strings with setNum().

    Many operators are overloaded to work with Q3CStrings. Q3CString
    also supports some more obscure functions, e.g. sprintf(),
    setStr() and setExpand().

    \sidebar Note on Character Comparisons

    In Q3CString the notion of uppercase and lowercase and of which
    character is greater than or less than another character is locale
    dependent. This affects functions which support a case insensitive
    option or which compare or lowercase or uppercase their arguments.
    Case insensitive operations and comparisons will be accurate if
    both strings contain only ASCII characters. (If \c $LC_CTYPE is
    set, most Unix systems do "the right thing".) Functions that this
    affects include contains(), find(), findRev(), \l operator<(), \l
    operator<=(), \l operator>(), \l operator>=(), lower() and
    upper().

    This issue does not apply to \l{QString}s since they represent
    characters using Unicode.
    \endsidebar

    Performance note: The Q3CString methods for QRegExp searching are
    implemented by converting the Q3CString to a QString and performing
    the search on that. This implies a deep copy of the Q3CString data.
    If you are going to perform many QRegExp searches on a large
    Q3CString, you will get better performance by converting the
    Q3CString to a QString yourself, and then searching in the QString.
*/

/*!
    \fn Q3CString Q3CString::left(uint len)  const

    \internal
*/

/*!
    \fn Q3CString Q3CString::right(uint len) const

    \internal
*/

/*!
    \fn Q3CString Q3CString::mid(uint index, uint len) const

    \internal
*/

/*!
    \fn Q3CString  Q3CString::lower() const

    Use QByteArray::toLower() instead.
*/

/*!
    \fn Q3CString  Q3CString::upper() const

    Use QByteArray::toUpper() instead.
*/

/*!
    \fn Q3CString  Q3CString::stripWhiteSpace() const

    Use QByteArray::trimmed() instead.
*/

/*!
    \fn Q3CString  Q3CString::simplifyWhiteSpace() const

    Use QByteArray::simplified() instead.
*/

/*!
    \fn Q3CString& Q3CString::insert(uint index, const char *c)

    \internal
*/

/*!
    \fn Q3CString& Q3CString::insert(uint index, char c)

    \internal
*/

/*!
    \fn Q3CString& Q3CString::prepend(const char *c)

    \internal
*/

/*!
    \fn Q3CString& Q3CString::remove(uint index, uint len)

    \internal
*/

/*!
    \fn Q3CString& Q3CString::replace(uint index, uint len, const char *c)

    \internal
*/

/*!
    \fn Q3CString& Q3CString::replace(char c, const Q3CString &after)

    \internal
*/

/*!
    \fn Q3CString& Q3CString::replace(char c, const char *after)

    \internal
*/

/*!
    \fn Q3CString& Q3CString::replace(const Q3CString &b, const Q3CString &a)

    \internal
*/

/*!
    \fn Q3CString& Q3CString::replace(const char *b, const char *a)

    \internal
*/

/*!
    \fn Q3CString& Q3CString::replace(char b, char a)

    \internal
*/

/*!
    \fn Q3CString::Q3CString()

    Constructs a null string.

    \sa isNull()
*/

/*!
    \fn Q3CString::Q3CString(const QByteArray &ba)

    Constructs a copy of \a ba.
*/

/*!
    \fn Q3CString::Q3CString(const Q3CString &s)

    Constructs a shallow copy \a s.
*/

/*! \fn Q3CString::Q3CString(int size)
    Constructs a string with room for \a size characters, including
    the '\0'-terminator. Makes a null string if \a size == 0.

    If \a size \> 0, then the first and last characters in the string
    are initialized to '\0'. All other characters are uninitialized.

    \sa resize(), isNull()
*/

/*! \fn Q3CString::Q3CString(const char *str)
    Constructs a string that is a deep copy of \a str.

    If \a str is 0 a null string is created.

    \sa isNull()
*/


/*! \fn Q3CString::Q3CString(const char *str, uint maxsize)

    Constructs a string that is a deep copy of \a str. The copy will
    be at most \a maxsize bytes long including the '\0'-terminator.

    Example:
    \snippet doc/src/snippets/code/src_qt3support_tools_q3cstring.cpp 0

    If \a str contains a 0 byte within the first \a maxsize bytes, the
    resulting Q3CString will be terminated by this 0. If \a str is 0 a
    null string is created.

    \sa isNull()
*/

/*!
    \fn Q3CString &Q3CString::operator=(const QByteArray &ba)

    Assigns byte array \a ba to this Q3CString.
*/

/*!
    \fn Q3CString &Q3CString::operator=(const Q3CString &s)

    Assigns a shallow copy of \a s to this string and returns a
    reference to this string.
*/

/*!
    \fn Q3CString &Q3CString::operator=(const char *str)
    \overload

    Assigns a deep copy of \a str to this string and returns a
    reference to this string.

    If \a str is 0 a null string is created.

    \sa isNull()
*/

/*
    \fn bool Q3CString::isNull() const

    Returns true if the string is null, i.e. if data() == 0; otherwise
    returns false. A null string is also an empty string.

    \note If you ask for the data pointer of a null Q3CString by
    calling data(), then because the internal representation of the
    null Q3CString is shared, it will be detached and replaced with a
    non-shared, empty representation, a non-null data pointer will be
    returned, and subsequent calls to isNull() will return false. But
    if you ask for the data pointer of a null Q3CString by calling
    constData(), the shared internal representation is not detached, a
    null data pointer is returned, and subsequent calls to isNull()
    will continue to return true.

    Example:
    \snippet doc/src/snippets/code/src.qt3support.tools.q3cstring.cpp 1

    \sa isEmpty(), length(), size()
*/

/*
    \fn bool Q3CString::isEmpty() const

    Returns true if the string is empty, i.e. if length() == 0;
    otherwise returns false. An empty string is not always a null
    string.

    See example in isNull().

    \sa isNull(), length(), size()
*/

/*
    \fn uint Q3CString::length() const

    Returns the length of the string, excluding the '\0'-terminator.
    Equivalent to calling \c strlen(data()).

    Null strings and empty strings have zero length.

    \sa size(), isNull(), isEmpty()
*/

/*
    \fn bool Q3CString::truncate(uint pos)

    Truncates the string at position \a pos.

    Equivalent to calling \c resize(pos+1).

    Example:
    \snippet doc/src/snippets/code/src.qt3support.tools.q3cstring.cpp 2

    \sa resize()
*/



/*!
    Implemented as a call to the native vsprintf() (see the manual for
    your C library).

    If the string is shorter than 256 characters, this sprintf() calls
    resize(256) to decrease the chance of memory corruption. The
    string is resized back to its actual length before sprintf()
    returns.

    Example:
    \snippet doc/src/snippets/code/src_qt3support_tools_q3cstring.cpp 3

    \warning All vsprintf() implementations will write past the end of
    the target string (*this) if the \a format specification and
    arguments happen to be longer than the target string, and some
    will also fail if the target string is longer than some arbitrary
    implementation limit.

    Giving user-supplied arguments to sprintf() is risky: Sooner or
    later someone will paste a huge line into your application.
*/

Q3CString &Q3CString::sprintf(const char *format, ...)
{
    detach();
    va_list ap;
    va_start(ap, format);
    if (size() < 256)
        resize(256);                // make string big enough
    qvsnprintf(data(), size(), format, ap);
    resize(qstrlen(constData()));
    va_end(ap);
    return *this;
}
void WindowMaterialGlazingInspectorView::onClearSelection()
{
  ModelObjectInspectorView::onClearSelection(); // call parent implementation
  detach();
}
Example #4
0
int main(int argc, char *argv[])
{
    int nsockets = 0;
    struct event listeners[10];

    parseargs(argc, argv);

    if (g_foreground == 0) {
        detach();
        g_logfile = fopen(g_logfilename, "a");
        g_log_set_default_handler(logger, NULL);
    }

    g_handle_base[0] = 'H';
    g_handle_base[1] = ':';
    if (gethostname(g_handle_base+2, 128-28) != 0) {
        sprintf(g_handle_base+2, "hostname"); /* TODO: figure out some other unique identifier */
    }
    char *p = strchr(g_handle_base, '.');
    if (!p) p = g_handle_base + strlen(g_handle_base);
    *(p++) = ':';
    *p = 0;

    g_thread_init(NULL);

    event_init();
    //printf("%s %s\n", event_get_version(), event_get_method());

    signal(SIGPIPE, SIG_IGN);

    struct event sig_int, sig_hup, sig_term;/*, sig_pipe;*/
    if (g_foreground) {
        event_set(&sig_int, SIGINT, EV_SIGNAL|EV_PERSIST, signal_cb, &sig_int);
        event_add(&sig_int, NULL);
        event_set(&sig_hup, SIGHUP, EV_SIGNAL|EV_PERSIST, signal_cb, &sig_hup);
        event_add(&sig_hup, NULL);
    } else {
        signal(SIGINT, SIG_IGN);
        signal(SIGHUP, SIG_IGN);
    }
    event_set(&sig_term, SIGTERM, EV_SIGNAL|EV_PERSIST, signal_cb, &sig_term);
    event_add(&sig_term, NULL);
    /*event_set(&sig_pipe, SIGPIPE, EV_SIGNAL|EV_PERSIST, signal_cb, &sig_pipe);
    event_add(&sig_pipe, NULL);*/

    int s = listen_on(inet_addr(g_bind), g_port);
    if (s == -1) {
        perror("failed to listen on port ...");
        return -1;
    }
    event_set(&listeners[nsockets], s, EV_READ|EV_PERSIST,
              listener_cb, &listeners[nsockets]);
    event_add(&listeners[nsockets], NULL);
    nsockets++;

    g_message("listening on port %d", g_port);

    g_clients   = g_ptr_array_new();
    g_jobs = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, (GDestroyNotify)job_free);
    g_jobqueue = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, (GDestroyNotify)g_queue_free);
    g_uniq_jobs = g_hash_table_new_full(uniq_job_hash, uniq_job_equal, NULL, NULL);
    g_workers = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, (GDestroyNotify)g_ptr_array_free);

    schedule_cleanup();

    g_message("gearmand running");
    event_dispatch();
    g_message("gearmand stopped");

    g_hash_table_destroy(g_workers);
    g_hash_table_destroy(g_uniq_jobs);
    g_hash_table_destroy(g_jobqueue);
    g_hash_table_destroy(g_jobs);
    g_ptr_array_free(g_clients, TRUE);

    freePools();

    if (g_foreground == 0)
        fclose(g_logfile);

    return 0;
}
Example #5
0
/*!
    Inserts the field \a field at position \a pos in the record.

    \sa append() replace() remove()
 */
void QSqlRecord::insert(int pos, const QSqlField& field)
{
   detach();
   d->fields.insert(pos, field);
}
Example #6
0
/*!
    \since 4.7

    Sets the outgoing option \a opt to value \a value.
    See \l{QAuthenticator#Options} for more information on outgoing options.

    \sa options(), option(), QAuthenticator#Options
*/
void QAuthenticator::setOption(const QString &opt, const QVariant &value)
{
    detach();
    d->options.insert(opt, value);
}
Example #7
0
 void attach(string_type& string) {
     detach();
     this->string = boost::addressof(string);
 }
void MaterialAirWallInspectorView::onClearSelection()
{
  ModelObjectInspectorView::onClearSelection(); // call parent implementation
  detach();
}
Example #9
0
QWSSharedMemory::~QWSSharedMemory()
{
    detach();
}
Example #10
0
/*!
   Sets the text option structure that controls the layout process to the given \a textOption.

   \sa textOption()
*/
void QStaticText::setTextOption(const QTextOption &textOption)
{
    detach();
    data->textOption = textOption;
    data->invalidate();
}
Example #11
0
/*!
    Sets the preferred width for this QStaticText. If the text is wider than the specified width,
    it will be broken into multiple lines and grow vertically. If the text cannot be split into
    multiple lines, it will be larger than the specified \a textWidth.

    Setting the preferred text width to a negative number will cause the text to be unbounded.

    Use size() to get the actual size of the text.

    \note This function will cause the layout of the text to require recalculation.

    \sa textWidth(), size()
*/
void QStaticText::setTextWidth(qreal textWidth)
{
    detach();
    data->textWidth = textWidth;
    data->invalidate();
}
Example #12
0
/*!
   Sets the text format of the QStaticText to \a textFormat. If \a textFormat is set to
   Qt::AutoText (the default), the format of the text will try to be determined using the
   function Qt::mightBeRichText(). If the text format is Qt::PlainText, then the text will be
   displayed as is, whereas it will be interpreted as HTML if the format is Qt::RichText. HTML tags
   that alter the font of the text, its color, or its layout are supported by QStaticText.

   \note This function will cause the layout of the text to require recalculation.

   \sa textFormat(), setText(), text()
*/
void QStaticText::setTextFormat(Qt::TextFormat textFormat)
{
    detach();
    data->textFormat = textFormat;
    data->invalidate();
}
Example #13
0
/*!
    Sets the text of the QStaticText to \a text.

    \note This function will cause the layout of the text to require recalculation.

    \sa text()
*/
void QStaticText::setText(const QString &text)
{
    detach();
    data->text = text;
    data->invalidate();
}
Example #14
0
/// Closes the file and throws on error.
void fstream::close (void)
{
    if (m_fd >= 0 && ::close(m_fd))
	set_and_throw (badbit | failbit, "close");
    detach();
}
Example #15
0
/*!
  Sets the \a user used for authentication.

  \sa QNetworkAccessManager::authenticationRequired()
*/
void QAuthenticator::setUser(const QString &user)
{
    detach();
    d->user = user;
    d->updateCredentials();
}
Example #16
0
void Plot2DProfile::detachFromPlot(){
    detach();
}
Example #17
0
/*!
  Sets the \a password used for authentication.

  \sa QNetworkAccessManager::authenticationRequired()
*/
void QAuthenticator::setPassword(const QString &password)
{
    detach();
    d->password = password;
}
 void TreeInspector::close(Event* ev)
 {
     detach();
     _getStage()->removeEventListeners(this);
     //return true;
 }
Example #19
0
/*!
  Destroys this QScriptDebuggerBackend.
*/
QScriptDebuggerBackend::~QScriptDebuggerBackend()
{
    detach();
}
Example #20
0
/*!
    Sets the number of samples per pixel for a multisample framebuffer object
    to \a samples.  The default sample count of 0 represents a regular
    non-multisample framebuffer object.

    If the desired amount of samples per pixel is not supported by the hardware
    then the maximum number of samples per pixel will be used. Note that
    multisample framebuffer objects can not be bound as textures. Also, the
    \c{GL_EXT_framebuffer_multisample} extension is required to create a
    framebuffer with more than one sample per pixel.

    \sa samples()
*/
void QGLFramebufferObjectFormat::setSamples(int samples)
{
    detach();
    d->samples = samples;
}
Example #21
0
//-------------------------------------------------------------------------------------
bool DBInterfaceMysql::attach(const char* databaseName)
{
	if(!_g_installedWatcher)
	{
		initializeWatcher();
	}

	if(db_port_ == 0)
		db_port_ = 3306;
	
	if(databaseName != NULL)
		kbe_snprintf(db_name_, MAX_BUF, "%s", databaseName);

	hasLostConnection_ = false;

	try
	{
		pMysql_ = mysql_init(0);
		if(pMysql_ == NULL)
		{
			ERROR_MSG("DBInterfaceMysql::attach: mysql_init is error!\n");
			return false;
		}
		
		DEBUG_MSG(fmt::format("DBInterfaceMysql::attach: connect: {}:{} starting...\n", db_ip_, db_port_));

		int ntry = 0;

__RECONNECT:
		if(mysql_real_connect(mysql(), db_ip_, db_username_, 
    		db_password_, db_name_, db_port_, NULL, 0)) // CLIENT_MULTI_STATEMENTS  
		{
			if(mysql_select_db(mysql(), db_name_) != 0)
			{
				ERROR_MSG(fmt::format("DBInterfaceMysql::attach: Could not set active db[{}]\n",
					db_name_));

				detach();
				return false;
			}
		}
		else
		{
			if (mysql_errno(pMysql_) == 1049 && ntry++ == 0)
			{
				if (mysql())
				{
					::mysql_close(mysql());
					pMysql_ = NULL;
				}

				pMysql_ = mysql_init(0);
				if (pMysql_ == NULL)
				{
					ERROR_MSG("DBInterfaceMysql::attach: mysql_init is error!\n");
					return false;
				}

				if (mysql_real_connect(mysql(), db_ip_, db_username_,
					db_password_, NULL, db_port_, NULL, 0)) // CLIENT_MULTI_STATEMENTS  
				{
					this->createDatabaseIfNotExist();
					if (mysql_select_db(mysql(), db_name_) != 0)
					{
						goto __RECONNECT;
					}
				}
				else
				{
					goto __RECONNECT;
				}
			}
			else
			{
				ERROR_MSG(fmt::format("DBInterfaceMysql::attach: mysql_errno={}, mysql_error={}\n",
					mysql_errno(pMysql_), mysql_error(pMysql_)));

				detach();
				return false;
			}
		}

		if (mysql_set_character_set(mysql(), "utf8") != 0)
		{
			ERROR_MSG("DBInterfaceMysql::attach: Could not set client connection character set to UTF-8\n" );
			return false;
		}

		// 不需要关闭自动提交,底层会START TRANSACTION之后再COMMIT
		// mysql_autocommit(mysql(), 0);

		char characterset_sql[MAX_BUF];
		kbe_snprintf(characterset_sql, MAX_BUF, "ALTER DATABASE CHARACTER SET %s COLLATE %s", 
			characterSet_.c_str(), collation_.c_str());

		query(&characterset_sql[0], strlen(characterset_sql), false);
	}
	catch (std::exception& e)
	{
		ERROR_MSG(fmt::format("DBInterfaceMysql::attach: {}\n", e.what()));
		hasLostConnection_ = true;
		detach();
		return false;
	}

	bool ret = mysql() != NULL && ping();

	if(ret)
	{
		DEBUG_MSG(fmt::format("DBInterfaceMysql::attach: successfully! addr: {}:{}\n", db_ip_, db_port_));
	}

    return ret;
}
Example #22
0
/*!
    Sets the attachment configuration of a framebuffer object to \a attachment.

    \sa attachment()
*/
void QGLFramebufferObjectFormat::setAttachment(QGLFramebufferObject::Attachment attachment)
{
    detach();
    d->attachment = attachment;
}
Example #23
0
void QSqlRecord::append(const QSqlField& field)
{
    detach();
    d->fields.append(field);
}
Example #24
0
/*! \internal */
void QGLFramebufferObjectFormat::setTextureTarget(QMacCompatGLenum target)
{
    detach();
    d->target = target;
}
Example #25
0
void QSqlRecord::clear()
{
    detach();
    d->fields.clear();
}
Example #26
0
/*! \internal */
void QGLFramebufferObjectFormat::setInternalTextureFormat(QMacCompatGLenum internalTextureFormat)
{
    detach();
    d->internal_format = internalTextureFormat;
}
Example #27
0
int main2(int argc, char **argv) {
	InitializeCriticalSection(&mutex);
	EnterCriticalSection(&mutex);
#endif
        char *priority = NULL;

	if(!detach())
		return 1;

#ifdef HAVE_MLOCKALL
	/* Lock all pages into memory if requested.
	 * This has to be done after daemon()/fork() so it works for child.
	 * No need to do that in parent as it's very short-lived. */
	if(do_mlock && mlockall(MCL_CURRENT | MCL_FUTURE) != 0) {
		logger(LOG_ERR, "System call `%s' failed: %s", "mlockall",
		   strerror(errno));
		return 1;
	}
#endif

	/* Setup sockets and open device. */

	if(!setup_network())
		goto end;

	/* Initiate all outgoing connections. */

	try_outgoing_connections();

	/* Change process priority */

        if(get_config_string(lookup_config(config_tree, "ProcessPriority"), &priority)) {
                if(!strcasecmp(priority, "Normal")) {
                        if (setpriority(NORMAL_PRIORITY_CLASS) != 0) {
                                logger(LOG_ERR, "System call `%s' failed: %s",
                                       "setpriority", strerror(errno));
                                goto end;
                        }
                } else if(!strcasecmp(priority, "Low")) {
                        if (setpriority(BELOW_NORMAL_PRIORITY_CLASS) != 0) {
                                       logger(LOG_ERR, "System call `%s' failed: %s",
                                       "setpriority", strerror(errno));
                                goto end;
                        }
                } else if(!strcasecmp(priority, "High")) {
                        if (setpriority(HIGH_PRIORITY_CLASS) != 0) {
                                logger(LOG_ERR, "System call `%s' failed: %s",
                                       "setpriority", strerror(errno));
                                goto end;
                        }
                } else {
                        logger(LOG_ERR, "Invalid priority `%s`!", priority);
                        goto end;
                }
        }

	/* drop privileges */
	if (!drop_privs())
		goto end;

	/* Start main loop. It only exits when tinc is killed. */

	status = main_loop();

	/* Shutdown properly. */

	ifdebug(CONNECTIONS)
		devops.dump_stats();

	close_network_connections();

end:
	logger(LOG_NOTICE, "Terminating");

#ifndef HAVE_MINGW
	remove_pid(pidfilename);
#endif

	free(priority);

	EVP_cleanup();
	ENGINE_cleanup();
	CRYPTO_cleanup_all_ex_data();
	ERR_remove_state(0);
	ERR_free_strings();

	exit_configuration(&config_tree);
	list_free(cmdline_conf);
	free_names();

	return status;
}
Example #28
0
void
AsyncIoThread::run()
{
  Request *request;

  // Create theMemoryChannel in the thread that will wait for it
  NdbMutex_Lock(theStartMutexPtr);
  theStartFlag = true;
  NdbMutex_Unlock(theStartMutexPtr);
  NdbCondition_Signal(theStartConditionPtr);

  while (1)
  {
    request = theMemoryChannelPtr->readChannel();
    if (!request || request->action == Request::end)
    {
      DEBUG(ndbout_c("Nothing read from Memory Channel in AsyncFile"));
      theStartFlag = false;
      return;
    }//if

    AsyncFile * file = request->file;
    m_current_request= request;
    switch (request->action) {
    case Request::open:
      file->openReq(request);
      if (request->error == 0 && request->m_do_bind)
        attach(file);
      break;
    case Request::close:
      file->closeReq(request);
      detach(file);
      break;
    case Request::closeRemove:
      file->closeReq(request);
      file->removeReq(request);
      detach(file);
      break;
    case Request::readPartial:
    case Request::read:
      file->readReq(request);
      break;
    case Request::readv:
      file->readvReq(request);
      break;
    case Request::write:
      file->writeReq(request);
      break;
    case Request::writev:
      file->writevReq(request);
      break;
    case Request::writeSync:
      file->writeReq(request);
      file->syncReq(request);
      break;
    case Request::writevSync:
      file->writevReq(request);
      file->syncReq(request);
      break;
    case Request::sync:
      file->syncReq(request);
      break;
    case Request::append:
      file->appendReq(request);
      break;
    case Request::append_synch:
      file->appendReq(request);
      file->syncReq(request);
      break;
    case Request::rmrf:
      file->rmrfReq(request, file->theFileName.c_str(),
                    request->par.rmrf.own_directory);
      break;
    case Request::end:
      theStartFlag = false;
      return;
    case Request::allocmem:
    {
      allocMemReq(request);
      break;
    }
    case Request::buildindx:
      buildIndxReq(request);
      break;
    case Request::suspend:
      if (request->par.suspend.milliseconds)
      {
        g_eventLogger->debug("Suspend %s %u ms",
                             file->theFileName.c_str(),
                             request->par.suspend.milliseconds);
        NdbSleep_MilliSleep(request->par.suspend.milliseconds);
        continue;
      }
      else
      {
        g_eventLogger->debug("Suspend %s",
                             file->theFileName.c_str());
        theStartFlag = false;
        return;
      }
    default:
      DEBUG(ndbout_c("Invalid Request"));
      abort();
      break;
    }//switch
    m_last_request = request;
    m_current_request = 0;

    // No need to signal as ndbfs only uses tryRead
    theReportTo->writeChannelNoSignal(request);
    m_fs.wakeup();
  }
}
Example #29
0
		void			detach(const char* name) { detach(sym(name)); }
Example #30
0
void Window_android::onDisplayDestroyed() {
    detach();
}