Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3f13c27

Browse files
committed
WIP on sockhub integration. Now it compiles.
1 parent603a97a commit3f13c27

File tree

6 files changed

+327
-241
lines changed

6 files changed

+327
-241
lines changed

‎contrib/pg_dtm/dtmd/Makefile‎

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
CC=gcc
22
CFLAGS=-g -O2 -Wall -Iinclude -D_LARGEFILE64_SOURCE# -DDEBUG
3-
LIBUV_PREFIX=$(HOME)/libuv-build
4-
LIBUV_CFLAGS=-I"$(LIBUV_PREFIX)/include" -L"$(LIBUV_PREFIX)/lib"
5-
LIBUV_LDFLAGS=-luv -pthread -lrt
3+
SOCKHUB_PREFIX=../sockhub
4+
SOCKHUB_CFLAGS=-I"$(SOCKHUB_PREFIX)"
5+
SOCKHUB_LDFLAGS=-lsockhub -L"$(SOCKHUB_PREFIX)"
66

77
SYSTEM=$(shell uname -s)
88
ifeq ($(SYSTEM),Darwin)
@@ -15,18 +15,18 @@ all: bin/dtmd
1515
@echo Done.
1616
@echo Feel free to run the tests with\'make check\'.
1717

18-
bin/dtmd: obj/eventwrap.o obj/main.o obj/parser.o obj/clog.o obj/clogfile.o obj/util.o obj/transaction.o obj/snapshot.o | bindir objdir
19-
$(CC) -o bin/dtmd$(CFLAGS)$(LIBUV_CFLAGS)\
20-
obj/eventwrap.o obj/main.o obj/parser.o\
18+
bin/dtmd: obj/server.o obj/main.o obj/clog.o obj/clogfile.o obj/util.o obj/transaction.o obj/snapshot.o | bindir objdir
19+
$(CC) -o bin/dtmd$(CFLAGS)\
20+
obj/server.o obj/main.o\
2121
obj/clog.o obj/clogfile.o obj/util.o obj/transaction.o\
2222
obj/snapshot.o\
23-
$(LIBUV_LDFLAGS)
23+
$(SOCKHUB_LDFLAGS)
2424

25-
obj/eventwrap.o: src/eventwrap.c | objdir
26-
$(CC) -c -o obj/eventwrap.o$(CFLAGS)$(LIBUV_CFLAGS) src/eventwrap.c
25+
obj/server.o: src/server.c | objdir
26+
$(CC) -c -o obj/server.o$(CFLAGS)$(SOCKHUB_CFLAGS) src/server.c
2727

28-
check: bin/util-test bin/clog-test bin/parser-test
29-
./check.sh utilparserclog
28+
check: bin/util-test bin/clog-test
29+
./check.sh util clog
3030

3131
obj/%.o: src/%.c | objdir
3232
$(CC)$(CFLAGS) -c -o$@$<
@@ -37,9 +37,6 @@ bin/util-test: obj/util-test.o obj/util.o | bindir
3737
bin/clog-test: obj/clog-test.o obj/clog.o obj/clogfile.o obj/util.o | bindir
3838
$(CC) -o bin/clog-test$(CFLAGS) obj/clog-test.o obj/clog.o obj/clogfile.o obj/util.o
3939

40-
bin/parser-test: obj/parser-test.o obj/parser.o | bindir
41-
$(CC) -o bin/parser-test$(CFLAGS) obj/parser-test.o obj/parser.o
42-
4340
bindir:
4441
mkdir -p bin
4542

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#ifndefPROTO_H
2+
#definePROTO_H
3+
4+
#defineCMD_RESERVE 'r'
5+
#defineCMD_BEGIN 'b'
6+
#defineCMD_FOR 'y'
7+
#defineCMD_AGAINST 'n'
8+
#defineCMD_SNAPSHOT 'h'
9+
#defineCMD_STATUS 's'
10+
11+
#defineRES_FAILED 0xDEADBEEF
12+
#defineRES_OK 0xC0FFEE
13+
#defineRES_TRANSACTION_COMMITTED 1
14+
#defineRES_TRANSACTION_ABORTED 2
15+
#defineRES_TRANSACTION_INPROGRESS 3
16+
#defineRES_TRANSACTION_UNKNOWN 4
17+
18+
#endif

‎contrib/pg_dtm/dtmd/include/server.h‎

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#ifndefSERVER_H
22
#defineSERVER_H
33

4+
#include<stdbool.h>
5+
46
/*
57
* You should not want to know what is inside those structures.
68
*/
@@ -34,7 +36,7 @@ server_t server_init(
3436
intport,
3537
onmessage_callback_tonmessage,
3638
onconnect_callback_tonconnect,
37-
ondisconnect_callback_tondisconnect,
39+
ondisconnect_callback_tondisconnect
3840
);
3941

4042
/*
@@ -53,17 +55,17 @@ void server_loop(server_t server);
5355
* 'client'. The server does not care about this data and will not free it on
5456
* client disconnection.
5557
*/
56-
voidclient_set_data(client_tclient,void*userdata);
57-
void*client_get_data(client_tclient);
58+
voidclient_set_userdata(client_tclient,void*userdata);
59+
void*client_get_userdata(client_tclient);
5860

5961
/*
6062
* Puts an empty message header into the output buffer of the corresponding
6163
* socket. The message will not be sent until you call the _finish() method.
6264
* A call to this function may lead to a send() call if there is not enough
6365
* space in the buffer.
64-
*
66+
*
6567
* Returns 'true' on success, 'false' otherwise.
66-
*
68+
*
6769
* NOTE: Be careful not to call the _message_ methods for other clients until
6870
* you _finish() this message. This limitation is due to the fact that multiple
6971
* clients share the same socket.
@@ -74,17 +76,25 @@ bool client_message_start(client_t client);
7476
* Appends 'len' bytes of 'data' to the buffer of the corresponding socket.
7577
* A call to this function may lead to a send() call if there is not enough
7678
* space in the buffer.
77-
*
79+
*
7880
* Returns 'true' on success, 'false' otherwise.
7981
*/
8082
boolclient_message_append(client_tclient,size_tlen,void*data);
8183

8284
/*
8385
* Finalizes the message. After finalizing the message becomes ready to be sent
8486
* over the corresponding socket, and you may _start() another message.
85-
*
87+
*
8688
* Returns 'true' on success, 'false' otherwise.
8789
*/
8890
boolclient_message_finish(client_tclient);
8991

92+
/*
93+
* A shortcut to perform all three steps in one, if you only have one number in
94+
* the message.
95+
*
96+
* Returns 'true' on success, 'false' otherwise.
97+
*/
98+
boolclient_message_shortcut(client_tclient,long longarg);
99+
90100
#endif

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp