summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorom <om@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-07 00:16:28 +0000
committerom <om@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-07 00:16:28 +0000
commit7e709ca6554dfb530521ecbe6943d8578392d46b (patch)
treee8b81020d3d228cf0d92a63bb925e643743c806e /src
parent88e6af302d00baf9a3e399f909e800ed91908185 (diff)
modules.*: Put some void* back to char*, sorry if they were only like that because of me... :p
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4119 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/modules.cpp4
-rw-r--r--src/modules/extra/m_pgsql.cpp64
2 files changed, 38 insertions, 30 deletions
diff --git a/src/modules.cpp b/src/modules.cpp
index 4e1dd0eac..4e98696bd 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -157,7 +157,7 @@ Version::Version(int major, int minor, int revision, int build, int flags) : Maj
Admin::Admin(std::string name, std::string email, std::string nick) : Name(name), Email(email), Nick(nick) { };
-Request::Request(void* anydata, Module* src, Module* dst) : data(anydata), source(src), dest(dst) { };
+Request::Request(char* anydata, Module* src, Module* dst) : data(anydata), source(src), dest(dst) { };
char* Request::GetData()
{
@@ -186,7 +186,7 @@ char* Request::Send()
}
}
-Event::Event(void* anydata, Module* src, const std::string &eventid) : data(anydata), source(src), id(eventid) { };
+Event::Event(char* anydata, Module* src, const std::string &eventid) : data(anydata), source(src), id(eventid) { };
char* Event::GetData()
{
diff --git a/src/modules/extra/m_pgsql.cpp b/src/modules/extra/m_pgsql.cpp
index dcadcaa46..e16f38e59 100644
--- a/src/modules/extra/m_pgsql.cpp
+++ b/src/modules/extra/m_pgsql.cpp
@@ -135,6 +135,11 @@ public:
exit(-1);
}
+ ~SQLConn()
+ {
+
+ }
+
bool DoResolve()
{
log(DEBUG, "Checking for DNS lookup result");
@@ -157,7 +162,7 @@ public:
else
{
log(DEBUG, "DNS lookup failed, dying horribly");
- DoError();
+ Close();
return false;
}
}
@@ -177,14 +182,14 @@ public:
if(!(sql = PQconnectStart(MkInfoStr().c_str())))
{
log(DEBUG, "Couldn't allocate PGconn structure, aborting: %s", PQerrorMessage(sql));
- DoError();
+ Close();
return false;
}
if(PQstatus(sql) == CONNECTION_BAD)
{
log(DEBUG, "PQconnectStart failed: %s", PQerrorMessage(sql));
- DoError();
+ Close();
return false;
}
@@ -193,7 +198,7 @@ public:
if(PQsetnonblocking(sql, 1) == -1)
{
log(DEBUG, "Couldn't set connection nonblocking: %s", PQerrorMessage(sql));
- DoError();
+ Close();
return false;
}
@@ -208,7 +213,7 @@ public:
if(this->fd <= -1)
{
log(DEBUG, "PQsocket says we have an invalid FD: %d", this->fd);
- DoError();
+ Close();
return false;
}
@@ -221,13 +226,13 @@ public:
return DoPoll();
}
- void DoError()
+ virtual void Close()
{
this->fd = -1;
this->state = I_ERROR;
this->OnError(I_ERR_SOCKET);
this->ClosePending = true;
- log(DEBUG,"SQLConn::DoError");
+ log(DEBUG,"SQLConn::Close");
if(sql)
{
@@ -253,7 +258,7 @@ public:
break;
case PGRES_POLLING_FAILED:
log(DEBUG, "PGconnectPoll: PGRES_POLLING_FAILED: %s", PQerrorMessage(sql));
- DoError();
+ Close();
return false;
case PGRES_POLLING_OK:
log(DEBUG, "PGconnectPoll: PGRES_POLLING_OK");
@@ -301,11 +306,6 @@ public:
}
}
- virtual void OnTimeout()
- {
- /* Unused, I think */
- }
-
virtual bool OnDataReady()
{
/* Always return true here, false would close the socket - we need to do that ourselves with the pgsql API */
@@ -365,16 +365,6 @@ public:
return true;
}
-
- virtual void OnClose()
- {
- /* Close PgSQL connection */
- }
-
- virtual void OnError(InspSocketError e)
- {
- /* Unsure if we need this, we should be reading/writing via the PgSQL API rather than the insp one... */
- }
std::string MkInfoStr()
{
@@ -409,6 +399,7 @@ public:
if(status == CWRITE) return "CWRITE";
if(status == WREAD) return "WREAD";
if(status == WWRITE) return "WWRITE";
+ return "Err...what, erm..BUG!";
}
bool Query(const std::string &query)
@@ -426,12 +417,26 @@ public:
return false;
}
}
- else
- {
- log(DEBUG, "Can't query until connection is complete");
- return false;
- }
+
+ log(DEBUG, "Can't query until connection is complete");
+ return false;
+ }
+
+ virtual void OnClose()
+ {
+ /* Close PgSQL connection */
+ }
+
+ virtual void OnError(InspSocketError e)
+ {
+ /* Unsure if we need this, we should be reading/writing via the PgSQL API rather than the insp one... */
+ }
+
+ virtual void OnTimeout()
+ {
+ /* Unused, I think */
}
+
};
class ModulePgSQL : public Module
@@ -444,6 +449,9 @@ public:
ModulePgSQL(Server* Me)
: Module::Module(Me), Srv(Me)
{
+ log(DEBUG, "%s 'SQL' feature", Srv->PublishFeature("SQL", this) ? "Published" : "Couldn't publish");
+ log(DEBUG, "%s 'PgSQL' feature", Srv->PublishFeature("PgSQL", this) ? "Published" : "Couldn't publish");
+
OnRehash("");
}