Skip to content

Commit ee9ab2c

Browse files
committed
- Fixed wsrep_listener.c compilation
- Moved wsrep_listener.c to under examples directory - Updated README.md - Updated .gitignore
1 parent 4bfbd0b commit ee9ab2c

File tree

6 files changed

+42
-7
lines changed

6 files changed

+42
-7
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
*.o
22
*.a
3+
*.diff
34
listener
5+
CMakeFiles
6+
CMakeCache.txt
7+
cmake_install.cmake
8+
Makefile

CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,4 @@ SET(WSREP_SOURCES wsrep_gtid.c wsrep_uuid.c wsrep_loader.c wsrep_dummy.c)
2323

2424
ADD_LIBRARY(wsrep ${WSREP_SOURCES})
2525

26-
#ADD_EXECUTABLE(listener wsrep_listener.c ${WSREP_SOURCES})
27-
#TARGET_LINK_LIBRARIES(listener ${LIBDL})
26+
ADD_SUBDIRECTORY(examples)

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1-
Write Set Replication API specification
1+
# Write Set Replication API specification
2+
3+
Building:
4+
```
5+
cmake . && make
6+
```

examples/CMakeLists.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright (c) 2018, Codership Oy. All rights reserved.
2+
#
3+
# This program is free software; you can redistribute it and/or modify
4+
# it under the terms of the GNU General Public License as published by
5+
# the Free Software Foundation; version 2 of the License.
6+
#
7+
# This program is distributed in the hope that it will be useful,
8+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10+
# GNU General Public License for more details.
11+
#
12+
# You should have received a copy of the GNU General Public License
13+
# along with this program; if not, write to the Free Software
14+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15+
16+
ADD_EXECUTABLE(listener listener.c)
17+
TARGET_LINK_LIBRARIES(listener wsrep dl pthread)

examples/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## wsrep API usage examples
2+
3+
### 1. Listener
4+
Is a simple program that connects and listens to replication events in
5+
an existing cluster.

wsrep_listener.c renamed to examples/listener.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ sst_request_cb (void* app_ctx __attribute__((unused)),
8585
if (*sst_req)
8686
*sst_req_len = strlen(*sst_req) + 1;
8787
else
88-
*sst_req_len = -ENOMEM;
88+
*sst_req_len = 0;
8989

9090
return WSREP_CB_SUCCESS;
9191
}
@@ -219,11 +219,15 @@ int main (int argc, char* argv[])
219219
}
220220

221221
/* Connect to cluster */
222-
rc = wsrep->connect (wsrep, cluster_name, wsrep_uri, "", 0);
222+
rc = wsrep->connect(wsrep, cluster_name, wsrep_uri, "", 0);
223223
if (0 != rc)
224224
{
225-
fprintf (stderr,
226-
"wsrep::connect() failed: %d (%s)\n", rc, strerror(-rc));
225+
if (rc < 0)
226+
fprintf (stderr, "wsrep::connect() failed: %d (%s)\n", rc,
227+
strerror(-(int)rc));
228+
else
229+
fprintf (stderr, "wsrep::connect() failed: %d\n", rc);
230+
227231
exit (EXIT_FAILURE);
228232
}
229233

0 commit comments

Comments
 (0)