Skip to content

Instantly share code, notes, and snippets.

@qpfiffer
Created July 3, 2014 19:20
Show Gist options
  • Save qpfiffer/5bb503264b903a29a191 to your computer and use it in GitHub Desktop.
Save qpfiffer/5bb503264b903a29a191 to your computer and use it in GitHub Desktop.
//// Makefile
MODULES = pg_webrtc
PG_CONFIG = pg_config
#PG_CPPFLAGS = -fPIC
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)
//// pg_webrtc.h
#include "postgres.h"
#include "postmaster/bgworker.h"
#include "storage/ipc.h"
#include "storage/latch.h"
#include "storage/proc.h"
#include "fmgr.h"
PG_MODULE_MAGIC;
void _PG_init();
void pg_webrtc_main(Datum main_arg);
//// pg_webrtc.cpp
#include "pg_webrtc.h"
void pg_webrtc_main(Datum main_arg) {
BackgroundWorkerUnblockSignals();
}
void _PG_init() {
BackgroundWorker worker;
worker.bgw_flags = BGWORKER_SHMEM_ACCESS;
worker.bgw_main = pg_webrtc_main;
worker.bgw_restart_time = 1;
worker.bgw_start_time = BgWorkerStart_RecoveryFinished;
snprintf(worker.bgw_name, BGW_MAXLEN, "pg_webrtc");
RegisterBackgroundWorker(&worker);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment