Skip to content

Commit 9e4b821

Browse files
committed
correction and clang
1 parent 7a8fc9d commit 9e4b821

7 files changed

Lines changed: 65 additions & 15 deletions

File tree

.github/workflows/auto-tag.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: Extract version from library.json
2424
id: version
2525
run: |
26-
VERSION=$(grep -m1 '"version"' library.json | sed -E 's/.*"version" *: *"([^"]+)".*/\1/')
26+
VERSION=$(jq -r '.version' library.json)
2727
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
2828
echo "Detected version: ${VERSION}"
2929

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
5151
- name: Create source archive
5252
run: |
53-
VERSION=$(grep '"version"' library.json | sed -E 's/.*"version" *: *"([^"]+)".*/\1/')
53+
VERSION=$(jq -r '.version' library.json)
5454
ARCHIVE="ESPAsyncWebClient-${VERSION}.zip"
5555
zip -r "$ARCHIVE" src examples README.md LICENSE library.json library.properties
5656
echo "Created $ARCHIVE"
@@ -64,7 +64,7 @@ jobs:
6464
- name: Extract changelog for this version
6565
id: changelog
6666
run: |
67-
VERSION=$(grep '"version"' library.json | sed -E 's/.*"version" *: *"([^"]+)".*/\1/')
67+
VERSION=$(jq -r '.version' library.json)
6868
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
6969
7070
# Extract the section for this version from CHANGELOG.md

scripts/sync-version.sh

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,75 @@ echo "Syncing version to ${NEW_VERSION} across all files..."
2121

2222
# 1. library.json
2323
if [[ -f library.json ]]; then
24-
sed -i -E "s/\"version\" *: *\"[^\"]+\"/\"version\": \"${NEW_VERSION}\"/" library.json
24+
python3 - <<'PY' "${NEW_VERSION}"
25+
import json
26+
import sys
27+
28+
new_version = sys.argv[1]
29+
path = "library.json"
30+
31+
with open(path, "r", encoding="utf-8") as f:
32+
data = json.load(f)
33+
34+
if not isinstance(data, dict) or "version" not in data:
35+
raise SystemExit("library.json missing top-level 'version' field")
36+
37+
data["version"] = new_version
38+
39+
with open(path, "w", encoding="utf-8", newline="\n") as f:
40+
json.dump(data, f, indent=2, ensure_ascii=False)
41+
f.write("\n")
42+
PY
2543
echo " ✓ library.json"
2644
else
2745
echo " ✗ library.json not found"
2846
fi
2947

3048
# 2. library.properties
3149
if [[ -f library.properties ]]; then
32-
sed -i -E "s/^version=.*/version=${NEW_VERSION}/" library.properties
50+
python3 - <<'PY' "${NEW_VERSION}"
51+
import re
52+
import sys
53+
54+
new_version = sys.argv[1]
55+
path = "library.properties"
56+
57+
with open(path, "r", encoding="utf-8") as f:
58+
text = f.read()
59+
60+
updated, count = re.subn(r"^version=.*$", f"version={new_version}", text, flags=re.MULTILINE)
61+
if count == 0:
62+
raise SystemExit("library.properties missing 'version=' line")
63+
64+
with open(path, "w", encoding="utf-8", newline="\n") as f:
65+
f.write(updated)
66+
PY
3367
echo " ✓ library.properties"
3468
else
3569
echo " ✗ library.properties not found"
3670
fi
3771

3872
# 3. src/HttpCommon.h
3973
if [[ -f src/HttpCommon.h ]]; then
40-
sed -i -E "s/#define ESP_ASYNC_WEB_CLIENT_VERSION \"[^\"]+\"/#define ESP_ASYNC_WEB_CLIENT_VERSION \"${NEW_VERSION}\"/" src/HttpCommon.h
74+
python3 - <<'PY' "${NEW_VERSION}"
75+
import re
76+
import sys
77+
78+
new_version = sys.argv[1]
79+
path = "src/HttpCommon.h"
80+
81+
with open(path, "r", encoding="utf-8") as f:
82+
text = f.read()
83+
84+
pattern = r'#define ESP_ASYNC_WEB_CLIENT_VERSION "[^"]+"'
85+
replacement = f'#define ESP_ASYNC_WEB_CLIENT_VERSION "{new_version}"'
86+
updated, count = re.subn(pattern, replacement, text)
87+
if count == 0:
88+
raise SystemExit("src/HttpCommon.h missing ESP_ASYNC_WEB_CLIENT_VERSION define")
89+
90+
with open(path, "w", encoding="utf-8", newline="\n") as f:
91+
f.write(updated)
92+
PY
4193
echo " ✓ src/HttpCommon.h"
4294
else
4395
echo " ✗ src/HttpCommon.h not found"

scripts/verify-release.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ pass() { echo "[OK] $1"; }
1010
if [[ ! -f library.json ]]; then fail "library.json missing"; fi
1111
if [[ ! -f library.properties ]]; then fail "library.properties missing"; fi
1212

13-
# Extract the first occurrence of a JSON key named "version" (top-level package version)
14-
VERSION_JSON=$(grep -m1 '"version"' library.json | sed -E 's/.*"version" *: *"([^"]+)".*/\1/')
13+
VERSION_JSON=$(jq -r '.version' library.json)
1514
VERSION_PROP=$(grep '^version=' library.properties | cut -d'=' -f2)
1615

1716
[[ -n "${VERSION_JSON}" ]] || fail "Could not extract version from library.json"

src/AsyncCookieJar.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ bool AsyncCookieJar::isIpLiteral(const String& host) const {
132132
}
133133

134134
bool AsyncCookieJar::normalizeCookieDomain(String& domain, const String& host, bool domainAttributeProvided,
135-
bool* outHostOnly) const {
135+
bool* outHostOnly) const {
136136
if (outHostOnly)
137137
*outHostOnly = true;
138138
String hostLower = host;
@@ -219,7 +219,7 @@ bool AsyncCookieJar::pathMatches(const String& cookiePath, const String& request
219219
}
220220

221221
bool AsyncCookieJar::cookieMatchesRequest(const StoredCookie& cookie, const AsyncHttpRequest* request,
222-
int64_t nowSeconds) const {
222+
int64_t nowSeconds) const {
223223
if (!request)
224224
return false;
225225
if (isCookieExpired(cookie, nowSeconds))

src/AsyncHttpClient.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,7 @@ void AsyncHttpClient::cleanup(RequestContext* context) {
10401040
}
10411041
// Guard against recursion: cleanup → tryDequeue → executeRequest → triggerError → cleanup → tryDequeue
10421042
// The outer tryDequeue's while-loop will handle remaining pending requests.
1043-
if (!_inTryDequeue)
1043+
if (!_inTryDequeue.load(std::memory_order_acquire))
10441044
tryDequeue();
10451045
}
10461046

@@ -1103,9 +1103,8 @@ void AsyncHttpClient::loop() {
11031103
}
11041104

11051105
void AsyncHttpClient::tryDequeue() {
1106-
if (_inTryDequeue)
1106+
if (_inTryDequeue.exchange(true, std::memory_order_acq_rel))
11071107
return; // prevent recursion via executeRequest → triggerError → cleanup → tryDequeue
1108-
_inTryDequeue = true;
11091108
while (true) {
11101109
lock();
11111110
bool canStart = (_maxParallel == 0 || _activeRequests.size() < _maxParallel);
@@ -1119,7 +1118,7 @@ void AsyncHttpClient::tryDequeue() {
11191118
unlock();
11201119
executeRequest(ctx);
11211120
}
1122-
_inTryDequeue = false;
1121+
_inTryDequeue.store(false, std::memory_order_release);
11231122
}
11241123

11251124
void AsyncHttpClient::sendStreamData(RequestContext* context) {

src/AsyncHttpClient.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ class AsyncHttpClient {
200200
AsyncHttpTLSConfig _defaultTlsConfig;
201201
bool _keepAliveEnabled = false;
202202
uint32_t _keepAliveIdleMs = 5000;
203-
bool _inTryDequeue = false; // reentrancy guard to prevent cleanup → tryDequeue recursion
203+
std::atomic_bool _inTryDequeue{false}; // cross-task reentrancy guard
204204
std::unique_ptr<AsyncCookieJar> _cookieJar;
205205
std::unique_ptr<ConnectionPool> _connectionPool;
206206
std::unique_ptr<RedirectHandler> _redirectHandler;

0 commit comments

Comments
 (0)