예제 #1
0
파일: connection.hpp 프로젝트: ablochs/fix8
	/*! 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);
	}
예제 #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;
	}
예제 #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;
	}
예제 #4
0
파일: f8c.hpp 프로젝트: xyuan/fix8
	~push_dir()
	{
		if (_cwd[0] && ::chdir(_cwd))
		{
			std::ostringstream ostr;
			ostr << "Error restoring previous directory '" << _cwd << "' (" << ::strerror(errno) << ')';
			throw f8Exception(ostr.str());
		}
	}
예제 #5
0
파일: f8c.hpp 프로젝트: xyuan/fix8
	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());
		}
	}
예제 #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
	}
예제 #7
0
파일: f8c.hpp 프로젝트: fix8/fix8
	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());
		}
	}
예제 #8
0
파일: f8c.hpp 프로젝트: fix8/fix8
	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());
		}
	}
예제 #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;
}
예제 #10
0
파일: ff_wrapper.hpp 프로젝트: jzsu/fix8
	f8_spin_lock()
	{
		if (pthread_spin_init(&_psl, PTHREAD_PROCESS_PRIVATE))
			throw f8Exception("pthread_spin_init failed");
	}
예제 #11
0
파일: ff_wrapper.hpp 프로젝트: jzsu/fix8
	f8_mutex()
	{
		if (pthread_mutex_init(&_pmutex, 0))
			throw f8Exception("pthread_mutex_init failed");
	}
예제 #12
0
파일: ff_wrapper.hpp 프로젝트: Microsz/fix8
	bool try_lock() { throw f8Exception("try_lock is not implemented in ff"); }