Skip to content

Commit 23dcd29

Browse files
Merge branch 'Torchship:main' into main
2 parents b521550 + f887bd5 commit 23dcd29

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+1615
-926
lines changed

.github/workflows/build.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Docker build and push to ECR
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
env:
9+
AWS_REGION: us-west-2
10+
ECR_REPOSITORY: torchstunt
11+
IMAGE_TAG: latest
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
id-token: write
18+
contents: read
19+
steps:
20+
- name: Check out repository
21+
uses: actions/checkout@v2
22+
23+
- name: Configure AWS Credentials
24+
uses: aws-actions/configure-aws-credentials@v2
25+
with:
26+
role-to-assume: arn:aws:iam::181720039072:role/GithubWorkflowActions
27+
aws-region: us-west-2
28+
29+
- name: Set up QEMU
30+
uses: docker/setup-qemu-action@v1
31+
32+
- name: Set up Docker Buildx
33+
uses: docker/setup-buildx-action@v1
34+
35+
- name: Login to Amazon ECR
36+
id: login-ecr
37+
uses: aws-actions/amazon-ecr-login@v1
38+
39+
- name: Build and push
40+
id: docker_build
41+
uses: docker/build-push-action@v2
42+
with:
43+
context: .
44+
file: ./Dockerfile
45+
push: true
46+
tags: ${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }}

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ version_src*.h
1010
keywords.c
1111
*.o
1212
moo
13+
bin
1314
\#*\#
1415
.\#*
1516
backups
@@ -21,7 +22,6 @@ xcode
2122
Makefile.in.bak
2223
keywords.cc
2324
build
24-
.vscode
2525
test/executables/true
2626
test/executables/sleep
2727
test/executables/echo

.vscode/launch.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Debug moo",
6+
"type": "cppdbg",
7+
"request": "launch",
8+
"program": "${workspaceFolder}/build/moo", // Path to your executable in the build folder
9+
"args": ["Minimal.db", "Minimal.out.db"], // Arguments for the program
10+
"stopAtEntry": false,
11+
"cwd": "${workspaceFolder}",
12+
"environment": [],
13+
"externalConsole": true,
14+
"MIMode": "gdb",
15+
"setupCommands": [
16+
{
17+
"description": "Enable pretty-printing for gdb",
18+
"text": "-enable-pretty-printing",
19+
"ignoreFailures": true
20+
}
21+
],
22+
"miDebuggerPath": "/usr/bin/gdb", // Ensure gdb is installed
23+
"preLaunchTask": "Build Project", // This will trigger the build task before debugging
24+
"miDebuggerArgs": "",
25+
"serverLaunchTimeout": 10000
26+
}
27+
]
28+
}

.vscode/settings.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"files.associations": {
3+
"system_error": "cpp",
4+
"regex": "cpp",
5+
"map": "cpp",
6+
"__tree": "cpp"
7+
}
8+
}

.vscode/tasks.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "Configure and Build Project",
6+
"type": "shell",
7+
"command": "cmake",
8+
"args": [
9+
"-B",
10+
"build",
11+
"-S",
12+
"."
13+
],
14+
"group": {
15+
"kind": "build",
16+
"isDefault": true
17+
},
18+
"problemMatcher": [
19+
"$gcc"
20+
],
21+
"detail": "Generated task for configuring the project with cmake"
22+
},
23+
{
24+
"label": "Build Project",
25+
"type": "shell",
26+
"command": "make",
27+
"args": [
28+
"-C",
29+
"build",
30+
"-j2"
31+
],
32+
"group": {
33+
"kind": "build",
34+
"isDefault": true
35+
},
36+
"problemMatcher": [
37+
"$gcc"
38+
],
39+
"detail": "Generated task for building the project in the build folder"
40+
}
41+
]
42+
}

CMakeLists.txt

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
cmake_minimum_required(VERSION 3.11)
22
set(VERSION_MAJOR 2)
33
set(VERSION_MINOR 7)
4-
set(VERSION_RELEASE 0)
4+
set(VERSION_RELEASE 1)
55
set(VERSION_EXT "")
66
project(ToastStunt VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_RELEASE} LANGUAGES CXX C)
77

8+
# Compile Options
9+
option(ONLY_32_BITS "Use 32-bit integers instead of 64-bit." OFF)
10+
option(USE_JEMALLOC "Use jemalloc (if available) for memory allocation." OFF)
11+
12+
# Fall back to 32-bit mode if the target doesn't support 64-bit
13+
if( CMAKE_SIZEOF_VOID_P EQUAL 4 )
14+
set(ONLY_32_BITS true)
15+
endif()
16+
817
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMakeModules/")
918

1019
# Don't bother if we don't have these
@@ -43,14 +52,6 @@ else()
4352
endif()
4453
endif()
4554

46-
# Compile Options
47-
option(ONLY_32_BITS "Use 32-bit integers instead of 64-bit." OFF)
48-
49-
# Fall back to 32-bit mode if the target doesn't support 64-bit
50-
if( CMAKE_SIZEOF_VOID_P EQUAL 4 )
51-
set(ONLY_32_BITS true)
52-
endif()
53-
5455
# Compiler Flags
5556
set(CMAKE_CXX_STANDARD 17)
5657
set(CMAKE_C_STANDARD 17)
@@ -142,16 +143,15 @@ add_custom_command(
142143
# Find packages. We don't do anything with the information yet because we need to know if things exist
143144
# to modify the source files, so we have to do it before moo is defined. But we can't
144145
# do the package setup UNTIL moo is defined.
145-
set(SQL_FOUND FALSE)
146-
IF(APPLE_SILICON_FOUND)
146+
if(APPLE_SILICON_FOUND)
147147
set(CMAKE_THREAD_LIBS_INIT "-lpthread")
148148
set(CMAKE_HAVE_THREADS_LIBRARY 1)
149149
set(CMAKE_USE_WIN32_THREADS_INIT 0)
150150
set(CMAKE_USE_PTHREADS_INIT 1)
151151
set(THREADS_PREFER_PTHREAD_FLAG ON)
152-
ELSE()
152+
else()
153153
find_package(Threads REQUIRED)
154-
ENDIF()
154+
endif()
155155
find_package(Nettle REQUIRED)
156156
find_package(Argon2 REQUIRED)
157157
find_package(PCRE)
@@ -163,6 +163,15 @@ find_package(MySQL)
163163
find_package(OpenSSL)
164164
find_package(Expat)
165165

166+
if(USE_JEMALLOC)
167+
find_library(JEMALLOC_LIBRARY NAMES jemalloc)
168+
if(NOT JEMALLOC_LIBRARY)
169+
message(WARNING "jemalloc library not found. Not using.")
170+
else()
171+
set(JEMALLOC_FOUND 1)
172+
endif()
173+
endif()
174+
166175
# Millions of source files
167176
set(src_CSRCS
168177
src/dependencies/thpool.c
@@ -310,6 +319,11 @@ if(OPENSSL_FOUND)
310319
target_link_libraries(moo ${OPENSSL_LIBRARIES})
311320
endif()
312321

322+
if(JEMALLOC_FOUND)
323+
include_directories(${JEMALLOC_INCLUDE_DIRS})
324+
target_link_libraries(moo ${JEMALLOC_LIBRARY})
325+
endif()
326+
313327
# Setup #defines as needed
314328
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/src/include/config.h.cmake
315329
${CMAKE_BINARY_DIR}/config.h)
@@ -324,3 +338,6 @@ endif()
324338
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
325339
message(STATUS "C flags: ${CMAKE_C_FLAGS}")
326340
message(STATUS "CXX flags: ${CMAKE_CXX_FLAGS}")
341+
if(JEMALLOC_FOUND)
342+
message(STATUS "Using jemalloc")
343+
endif()

Dockerfile

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM debian:buster-slim as builder
1+
FROM debian:12.2-slim as builder
22
RUN apt update && apt install -y libboost-all-dev libpq-dev libpq5 wget bison gperf libsqlite3-dev libexpat1-dev git libaspell-dev cmake libpcre3-dev nettle-dev g++ libcurl4-openssl-dev libargon2-dev libssl-dev
33

44
# Need to upgrade to a better CMAKE version, as we're super cool bleeding edge neato.
@@ -13,7 +13,7 @@ RUN ln -s /opt/cmake-3.24.0-rc4-linux-x86_64/bin/* /usr/local/bin
1313
RUN git clone https://github.com/jtv/libpqxx.git
1414
WORKDIR /opt/libpqxx
1515
RUN git checkout 7.6
16-
RUN pwd ; cmake . && make -j2 && make install
16+
RUN pwd ; cmake -DCMAKE_BUILD_TYPE=LeakCheck . && make -j2 && make install
1717

1818
# Moving on to building toaststunt...
1919
WORKDIR /toaststunt
@@ -27,7 +27,7 @@ RUN pwd ; mkdir build && cd build && cmake ../
2727
RUN cd /toaststunt/build && make -j2
2828

2929
# Make an entirely new image...
30-
FROM debian:buster-slim
30+
FROM debian:12.2-slim
3131

3232
# Bring over only necessary packages
3333
RUN apt update && apt install -y tini libpq-dev libpq5 libsqlite3-dev libexpat1-dev libaspell-dev libpcre3-dev nettle-dev libcurl4-openssl-dev libargon2-dev libssl-dev
@@ -40,12 +40,9 @@ COPY --from=builder \
4040
/usr/local/lib/libpqxx* \
4141
/usr/local/lib/
4242

43-
# Add Tini
44-
ENTRYPOINT ["/tini", "--"]
45-
4643
# A special restart which output on stdout is needed for docker
4744
COPY docker_restart.sh /toaststunt/
4845
RUN chmod +x /toaststunt/docker_restart.sh
4946
EXPOSE 7777
5047
WORKDIR /toaststunt/
51-
CMD ["./docker_restart", "/cores/${CORE_TO_LOAD}"]
48+
ENTRYPOINT ./docker_restart.sh /cores/$CORE_TO_LOAD

docs/ChangeLog.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@
1010
- Replaced waif counter with dictionary
1111
- Added tokenize_input() which takes strings written by players and tokenizes them into contextually aware verbs, macros, targets, and pronouns.
1212

13+
## 2.7.1 (Sep 17, 2023)
14+
### Bug Fixes
15+
- Various 64-bit compatibility fixes.
16+
- PCRE cache no longer ignores the case sensitive option. And other improvements.
17+
- Fix various race conditions.
18+
- Fix a memory leak when LOG_CODE_CHANGES is enabled and you program a verb and then remove it.
19+
20+
### New Features
21+
- Each connection now has an option to enable TCP keep-alives. These can be configured with `set_connection_option` by either specifying 1 (to enable and use defaults) or by specifying a map of options. The option keys are: idle, interval, and count. More information on what they do, and default values, can be found in options.h.
22+
- `listen()` now accepts a new key in its option map: interface. This allows you to specify the interface to listen on. (Similar to the --ipv4 or --ipv6 command-line arguments.)
23+
- `listeners()` now shows the interface being listened on.
24+
1325
## 2.7.0 (Mar 5, 2023)
1426
### Bug Fixes
1527
- Fix a memory leak in `open_network_connection()` that occurred after a successful connection.

docs/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ make -j2
107107
108108
### **Gentoo**
109109
```bash
110-
emerge app-text/aspell app-dicts/aspell-en app-crypt/argon2 cmake
110+
emerge app-text/aspell app-dicts/aspell-en app-crypt/argon2 dev-utils/cmake dev-libs/libpcre
111111
mkdir build && cd build
112112
cmake ../
113113
make -j2
@@ -146,7 +146,7 @@ There are a few build options available to developers:
146146
| Warn | Optimizations enabled, warnings enabled. (Previous default behavior) |
147147
| LeakCheck | Minimal optimizations enabled, debug enabled, and address sanitizer enabled. |
148148
149-
To change the build, use: `cmake -D CMAKE_BUILD_TYPE:STRING=BuildNameHere ../`
149+
To change the build, use: `cmake -DCMAKE_BUILD_TYPE=BuildNameHere ../`
150150
151151
### Login screen not showing
152152
Due to the way proxy detection works, if you're connecting to your MOO from localhost, you won't see the login screen. This is a minor inconvenience and shouldn't affect your ability to actually use your MOO. However, if it bothers you, you can disable HAProxy rewriting:

src/argon2.cc

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include "map.h"
1111
#include "background.h"
1212

13-
static void argon2_thread_callback(Var arglist, Var *r)
13+
static void argon2_thread_callback(Var arglist, Var *r, void *extra_data)
1414
{
1515
const int nargs = arglist.v.list[0].v.num;
1616

@@ -60,20 +60,17 @@ bf_argon2(Var arglist, Byte next, void *vdata, Objid progr)
6060
}
6161

6262
#ifdef THREAD_ARGON2
63-
char *human_string = nullptr;
64-
asprintf(&human_string, "argon2");
65-
66-
return background_thread(argon2_thread_callback, &arglist, human_string);
63+
return background_thread(argon2_thread_callback, &arglist);
6764
#else
6865
Var ret;
69-
argon2_thread_callback(arglist, &ret);
66+
argon2_thread_callback(arglist, &ret, nullptr);
7067

7168
free_var(arglist);
7269
return make_var_pack(ret);
7370
#endif
7471
}
7572

76-
static void argon2_verify_thread_callback(Var arglist, Var *r)
73+
static void argon2_verify_thread_callback(Var arglist, Var *r, void *extra_data)
7774
{
7875
const char *encoded = arglist.v.list[1].v.str;
7976
const char *str = arglist.v.list[2].v.str;
@@ -98,13 +95,10 @@ bf_argon2_verify(Var arglist, Byte next, void *vdata, Objid progr)
9895
}
9996

10097
#ifdef THREAD_ARGON2
101-
char *human_string = nullptr;
102-
asprintf(&human_string, "argon2_verify");
103-
104-
return background_thread(argon2_verify_thread_callback, &arglist, human_string);
98+
return background_thread(argon2_verify_thread_callback, &arglist);
10599
#else
106100
Var ret;
107-
argon2_verify_thread_callback(arglist, &ret);
101+
argon2_verify_thread_callback(arglist, &ret, nullptr);
108102

109103
free_var(arglist);
110104
return make_var_pack(ret);

0 commit comments

Comments
 (0)