Skip to content

Instantly share code, notes, and snippets.

View methodmissing's full-sized avatar

Lourens Naudé methodmissing

View GitHub Profile
#!/usr/sbin/dtrace -Zs
/*
* rb_syscalls.d - count Ruby calls and syscalls using DTrace.
* Written for the Ruby DTrace provider.
*
* $Id: rb_syscalls.d 20 2007-09-12 09:28:22Z brendan $
*
* USAGE: rb_syscalls.d { -p PID | -c cmd } # hit Ctrl-C to end
*
* FIELDS:
static void schedule_query(VALUE obj, VALUE timeout)
{
MYSQL* m = GetHandler(obj);
fd_set read;
timeout = ( NIL_P(timeout) ? m->net.read_timeout : INT2NUM(timeout) );
struct timeval tv = { tv_sec: timeout, tv_usec: 0 };
FD_ZERO(&read);
static VALUE mysqlres2obj(MYSQL_RES* res)
{
VALUE obj;
struct mysql_res* resp;
obj = Data_Make_Struct(cMysqlRes, struct mysql_res, 0, free_mysqlres, resp);
rb_iv_set(obj, "colname", Qnil);
rb_iv_set(obj, "tblcolname", Qnil);
resp->res = res;
resp->freed = Qfalse;
rb_obj_call_init(obj, 0, NULL);
diff --git a/ext/extconf.rb b/ext/extconf.rb
index d14738e..73bef6d 100644
--- a/ext/extconf.rb
+++ b/ext/extconf.rb
@@ -71,4 +71,4 @@ File.open('error_const.h', 'w') do |f|
end
end
-create_makefile("mysql")
+create_makefile("mysql")
require 'mysqlplus'
ActiveRecord::ConnectionAdapters::MysqlAdapter.class_eval do
def execute(sql, name = nil) #:nodoc:
if @connection.respond_to?(:send_query)
log(sql, "Async result #{name || ''}") { @connection.async_query(sql) }
else
log(sql, name) { @connection.query(sql) }
end
static VALUE
pgconn_async_exec(obj, str)
VALUE obj, str;
{
PGconn *conn = get_pgconn(obj);
PGresult *result;
char *msg;
int cs;
int ret;
HoptoadNotifier::Catcher.class_eval do
alias :original_send_to_hoptoad :send_to_hoptoad
def send_to_hoptoad data
async_hoptoad_notification? ? async_send_to_hoptoad( data ) : original_send_to_hoptoad( data )
end
def async_hoptoad_notification?
if Object.const_defined?(:EventMachine)
diff --git a/ext/mysql.c b/ext/mysql.c
index b804723..de9d435 100644
--- a/ext/mysql.c
+++ b/ext/mysql.c
@@ -61,6 +61,7 @@ struct mysql {
char connection;
char query_with_result;
char blocking;
+ int async_in_progress;
};
# Sequentially step through all of the available initialization routines,
# in order (view execution order in source).
def process
Rails.configuration = configuration
check_ruby_version
install_gem_spec_stubs
set_load_path
add_gem_load_paths
diff --git a/ext/mysql.c b/ext/mysql.c
index b804723..3f1a908 100644
--- a/ext/mysql.c
+++ b/ext/mysql.c
@@ -61,6 +61,7 @@ struct mysql {
char connection;
char query_with_result;
char blocking;
+ int async_in_progress;
};