Exemple #1
0
	/*! Send Fix message directly
	    \param from message to send
	    \return true in success */
	bool write(Message& from)
	{
		if (_pmodel == pm_pipeline) // not permitted if pipeling
			throw f8Exception("cannot send message directly if pipelining");
		f8_scoped_spin_lock guard(_con_spl);
		return _session.send_process(&from);
	}
Exemple #2
0
	/*! Add a T* to the manager; takes ownership of the object
	  \param name unique name for this session
	  \param what T* to add
	  \return true if successful */
	bool add(const f8String& name, T *what)
	{
		if (!what)
			throw f8Exception("bad or missing session");
		f8_scoped_lock guard(_mutex);
		return _sessionmap.insert({name, what}).second;
	}
Exemple #3
0
	/*! Add a ServerSession to the manager; takes ownership of the object
	  \param what ServerSession to add
	  \return true if successful */
	bool add(ServerSessionBase *what)
	{
		if (!what || !what->_server_sock)
			throw f8Exception("bad or missing server socket");
		_servermap.insert({*what->_server_sock, what});
		return true;
	}
Exemple #4
0
	~push_dir()
	{
		if (_cwd[0] && ::chdir(_cwd))
		{
			std::ostringstream ostr;
			ostr << "Error restoring previous directory '" << _cwd << "' (" << ::strerror(errno) << ')';
			throw f8Exception(ostr.str());
		}
	}
Exemple #5
0
	push_dir(const std::string& to) : _cwd()
	{
#ifdef _MSC_VER
		if (_getcwd(_cwd, MAX_FLD_LENGTH) == 0)
#else
		if (::getcwd(_cwd, MAX_FLD_LENGTH) == 0)
#endif
		{
			std::ostringstream ostr;
			ostr << "Error getting current directory (" << ::strerror(errno) << ')';
			throw f8Exception(ostr.str());
		}
		if (::chdir(to.c_str()))
		{
			std::ostringstream ostr;
			ostr << "Error setting new directory '" << to << "' (" << ::strerror(errno) << ')';
			throw f8Exception(ostr.str());
		}
	}
Exemple #6
0
	/*! Send Fix message directly
	    \param from message to send
	    \return true in success */
	bool write(Message& from)
	{
		if (_pmodel == pm_pipeline) // not permitted if pipeling
			throw f8Exception("cannot send message directly if pipelining");
#if defined MSGRECYCLING
		const bool result(_session.send_process(&from));
		from.set_in_use(false);
		return result;
#else
		return _session.send_process(&from);
#endif
	}
Exemple #7
0
	void getdir()
	{
#ifdef _MSC_VER
		if (_getcwd(_cwd, FIX8_MAX_FLD_LENGTH) == 0)
#else
		if (::getcwd(_cwd, FIX8_MAX_FLD_LENGTH) == 0)
#endif
		{
			std::ostringstream ostr;
			ostr << "Error getting current directory (" << ::strerror(errno) << ')';
			throw f8Exception(ostr.str());
		}
	}
Exemple #8
0
	void chgdir(const char *to) const
	{
#ifdef _MSC_VER
		if (!to || _chdir(to))
#else
		if (!to || ::chdir(to))
#endif
		{
			std::ostringstream ostr;
			ostr << "Error changing to directory '" << (to ? to : "(null)") << '\'';
			if (errno)
				ostr << " (" << ::strerror(errno) << ')';
			throw f8Exception(ostr.str());
		}
	}
Exemple #9
0
//-------------------------------------------------------------------------------------------------
Logger *Configuration::create_logger(const XmlElement *from, const Logtype ltype, const SessionID *sid) const
{
	string name;
	if (from && from->GetAttr(ltype == session_log ? "session_log" : "protocol_log", name))
	{
		const XmlElement *which(find_logger(name));
		if (which)
		{
			string type;
			if (which->GetAttr("type", type)
				&& ((type % "session" && ltype == session_log) || (type % "protocol" && ltype == protocol_log)))
			{
				string logname("logname_not_set.log");
				which->FindAttrRef("filename", logname);
				trim(logname);

				if (logname[0] == '|')
#ifndef HAVE_POPEN
					throw f8Exception("popen not supported on your platform");
#endif
					return new PipeLogger(logname, get_logflags(which));

				RegMatch match;
				if (_ipexp.SearchString(match, logname, 3) == 3)
				{
					f8String ip, port;
					_ipexp.SubExpr(match, logname, ip, 0, 1);
					_ipexp.SubExpr(match, logname, port, 0, 2);
					BCLogger *bcl(new BCLogger(ip, get_value<unsigned>(port), get_logflags(which)));
					if (*bcl)
						return bcl;
				}

				get_logname(which, logname, sid); // only applies to file loggers
				return new FileLogger(logname, get_logflags(which), get_logfile_rotation(which));
			}
		}
	}

	return 0;
}
Exemple #10
0
	f8_spin_lock()
	{
		if (pthread_spin_init(&_psl, PTHREAD_PROCESS_PRIVATE))
			throw f8Exception("pthread_spin_init failed");
	}
Exemple #11
0
	f8_mutex()
	{
		if (pthread_mutex_init(&_pmutex, 0))
			throw f8Exception("pthread_mutex_init failed");
	}
Exemple #12
0
	bool try_lock() { throw f8Exception("try_lock is not implemented in ff"); }