Skip to content

Commit

Permalink
Remove unused parameters and ptrs on WriteToUDP()
Browse files Browse the repository at this point in the history
  • Loading branch information
hodduc committed Jun 11, 2015
1 parent e7a3497 commit 7d98072
Show file tree
Hide file tree
Showing 15 changed files with 27 additions and 27 deletions.
8 changes: 4 additions & 4 deletions go_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

#include "_cgo_export.h"

void WriteToUDP_C(void* go_udp_conn, void* peer_address, void* buffer, size_t buf_len, void* quic_server_packet_writer, void* go_task_runner) {
WriteToUDP(go_udp_conn, peer_address, buffer, buf_len, quic_server_packet_writer, go_task_runner, 1);
void WriteToUDP_C(void* go_udp_conn, void* peer_address, void* buffer, size_t buf_len) {
WriteToUDP(go_udp_conn, peer_address, buffer, buf_len);
}

void WriteToUDPClient_C(void* go_udp_conn, void* peer_address, void* buffer, size_t buf_len, void* quic_server_packet_writer, void* go_task_runner) {
WriteToUDP(go_udp_conn, peer_address, buffer, buf_len, quic_server_packet_writer, go_task_runner, 0);
void WriteToUDPClient_C(void* go_udp_conn, void* peer_address, void* buffer, size_t buf_len) {
WriteToUDPClient(go_udp_conn, peer_address, buffer, buf_len);
}

void* CreateGoSession_C(void* go_quic_dispatcher, void* quic_server_session) {
Expand Down
4 changes: 2 additions & 2 deletions go_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#ifdef __cplusplus
extern "C" {
#endif
void WriteToUDP_C(void* go_udp_conn, void* peer_address, void* buffer, size_t buf_len, void* quic_server_packet_writer, void* go_task_runner);
void WriteToUDPClient_C(void* go_udp_conn, void* peer_address, void* buffer, size_t buf_len, void* quic_server_packet_writer, void* go_task_runner);
void WriteToUDP_C(void* go_udp_conn, void* peer_address, void* buffer, size_t buf_len);
void WriteToUDPClient_C(void* go_udp_conn, void* peer_address, void* buffer, size_t buf_len);
void* CreateGoSession_C(void* go_quic_dispatcher, void* quic_server_session);
void* DeleteGoSession_C(void* go_quic_dispatcher, void* go_quic_server_session);
int GetProof_C(void* go_quic_dispatcher, void* server_ip, char* hostname, size_t hostname_sz, char* server_config, size_t server_config_sz, int ecdsa_ok, char ***out_certs, int *out_certs_sz, size_t **out_certs_item_sz, char **out_signature, size_t *out_signature_sz);
Expand Down
13 changes: 11 additions & 2 deletions goquic.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ func SetLogLevel(level int) {
C.set_log_level(C.int(level))
}

//export WriteToUDP
func WriteToUDP(conn_c unsafe.Pointer, ip_endpoint_c unsafe.Pointer, buffer_c unsafe.Pointer, length_c C.size_t, server_packet_writer_c unsafe.Pointer, task_runner_c unsafe.Pointer, isServer bool) {
func writeToUDP(conn_c unsafe.Pointer, ip_endpoint_c unsafe.Pointer, buffer_c unsafe.Pointer, length_c C.size_t, isServer bool) {
conn := (*net.UDPConn)(conn_c)
endpoint := IPEndPoint{
ipEndPoint: ip_endpoint_c,
Expand All @@ -36,3 +35,13 @@ func WriteToUDP(conn_c unsafe.Pointer, ip_endpoint_c unsafe.Pointer, buffer_c un
conn.Write(buf)
}
}

//export WriteToUDP
func WriteToUDP(conn_c unsafe.Pointer, ip_endpoint_c unsafe.Pointer, buffer_c unsafe.Pointer, length_c C.size_t) {
writeToUDP(conn_c, ip_endpoint_c, buffer_c, length_c, true)
}

//export WriteToUDPClient
func WriteToUDPClient(conn_c unsafe.Pointer, ip_endpoint_c unsafe.Pointer, buffer_c unsafe.Pointer, length_c C.size_t) {
writeToUDP(conn_c, ip_endpoint_c, buffer_c, length_c, false)
}
Binary file modified lib/linux_amd64/libcrypto.a
Binary file not shown.
Binary file modified lib/linux_amd64/libgoquic.a
Binary file not shown.
Binary file modified lib/linux_amd64/libprotobuf.a
Binary file not shown.
Binary file modified lib/linux_amd64/libquic.a
Binary file not shown.
Binary file modified lib/linux_amd64/libssl.a
Binary file not shown.
2 changes: 1 addition & 1 deletion src/adaptor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ GoQuicDispatcher *create_quic_dispatcher(void* go_udp_conn, void* go_quic_dispat
helper,
go_quic_dispatcher);

GoQuicServerPacketWriter* writer = new GoQuicServerPacketWriter(go_udp_conn, dispatcher, go_task_runner); // Deleted by scoped ptr of GoQuicDispatcher
GoQuicServerPacketWriter* writer = new GoQuicServerPacketWriter(go_udp_conn, dispatcher); // Deleted by scoped ptr of GoQuicDispatcher

dispatcher->Initialize(writer);

Expand Down
2 changes: 1 addition & 1 deletion src/adaptor_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ GoQuicClientSession* create_go_quic_client_session_and_initialize(void* go_udp_c

TestConnectionHelper* helper = new TestConnectionHelper(task_runner, clock, random_generator); // Deleted by delete_go_quic_client_session()

QuicPacketWriter* writer = new GoQuicClientPacketWriter(go_udp_conn, task_runner); // Deleted by ~QuicConnection() because owns_writer is true
QuicPacketWriter* writer = new GoQuicClientPacketWriter(go_udp_conn); // Deleted by ~QuicConnection() because owns_writer is true

QuicVersionVector supported_versions;
for (size_t i = 0; i < arraysize(kSupportedQuicVersions); ++i) {
Expand Down
4 changes: 2 additions & 2 deletions src/go_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#ifdef __cplusplus
extern "C" {
#endif
void WriteToUDP_C(void* go_udp_conn, void* peer_address, void* buffer, size_t buf_len, void* quic_server_packet_writer, void* go_task_runner);
void WriteToUDPClient_C(void* go_udp_conn, void* peer_address, void* buffer, size_t buf_len, void* quic_server_packet_writer, void* go_task_runner);
void WriteToUDP_C(void* go_udp_conn, void* peer_address, void* buffer, size_t buf_len);
void WriteToUDPClient_C(void* go_udp_conn, void* peer_address, void* buffer, size_t buf_len);
void* CreateGoSession_C(void* go_quic_dispatcher, void* quic_server_session);
void* DeleteGoSession_C(void* go_quic_dispatcher, void* go_quic_server_session);
int GetProof_C(void* go_quic_dispatcher, void* server_ip, char* hostname, size_t hostname_sz, char* server_config, size_t server_config_sz, int ecdsa_ok, char ***out_certs, int *out_certs_sz, size_t **out_certs_item_sz, char **out_signature, size_t *out_signature_sz);
Expand Down
5 changes: 2 additions & 3 deletions src/go_quic_client_packet_writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@

namespace net {

GoQuicClientPacketWriter::GoQuicClientPacketWriter(void* go_udp_conn, void* go_task_runner)
GoQuicClientPacketWriter::GoQuicClientPacketWriter(void* go_udp_conn)
: go_udp_conn_(go_udp_conn),
go_task_runner_(go_task_runner),
write_blocked_(false) {
}

Expand All @@ -44,7 +43,7 @@ WriteResult GoQuicClientPacketWriter::WritePacket(
DCHECK(!IsWriteBlocked());
int rv;
if (buf_len <= static_cast<size_t>(std::numeric_limits<int>::max())) {
WriteToUDPClient_C(go_udp_conn_, (void *)(&peer_address), (void *)buffer, buf_len, (void *)this, go_task_runner_);
WriteToUDPClient_C(go_udp_conn_, (void *)(&peer_address), (void *)buffer, buf_len);

rv = buf_len;
} else {
Expand Down
5 changes: 1 addition & 4 deletions src/go_quic_client_packet_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ struct WriteResult;

class GoQuicClientPacketWriter : public QuicPacketWriter {
public:
GoQuicClientPacketWriter(void *go_udp_conn,
void* go_task_runner);
GoQuicClientPacketWriter(void *go_udp_conn);
~GoQuicClientPacketWriter() override;

// QuicPacketWriter implementation:
Expand All @@ -32,8 +31,6 @@ class GoQuicClientPacketWriter : public QuicPacketWriter {
private:
void* go_udp_conn_;

void* go_task_runner_;

// Whether a write is currently in flight.
bool write_blocked_;

Expand Down
6 changes: 2 additions & 4 deletions src/go_quic_server_packet_writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ namespace net {

GoQuicServerPacketWriter::GoQuicServerPacketWriter(
void* go_udp_conn,
QuicBlockedWriterInterface* blocked_writer,
void* go_task_runner)
QuicBlockedWriterInterface* blocked_writer)
: go_udp_conn_(go_udp_conn),
go_task_runner_(go_task_runner),
blocked_writer_(blocked_writer),
write_blocked_(false),
weak_factory_(this) {
Expand Down Expand Up @@ -79,7 +77,7 @@ WriteResult GoQuicServerPacketWriter::WritePacket(
/* TODO(hodduc) See quic_time_wait_list_manager.cc:WriteToWire. It should call WritePacketWithCallback to hold callback, but it isn't now. Google has been notified of this bug. */
int rv;
if (buf_len <= static_cast<size_t>(std::numeric_limits<int>::max())) {
WriteToUDP_C(go_udp_conn_, (void *)(&peer_address), (void *)buffer, buf_len, (void *)this, go_task_runner_);
WriteToUDP_C(go_udp_conn_, (void *)(&peer_address), (void *)buffer, buf_len);
rv = buf_len;
} else {
rv = ERR_MSG_TOO_BIG;
Expand Down
5 changes: 1 addition & 4 deletions src/go_quic_server_packet_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ class GoQuicServerPacketWriter : public QuicPacketWriter {
typedef base::Callback<void(WriteResult)> WriteCallback;

GoQuicServerPacketWriter(void *go_udp_conn,
QuicBlockedWriterInterface* blocked_writer,
void* go_task_runner);
QuicBlockedWriterInterface* blocked_writer);
~GoQuicServerPacketWriter() override;

// Use this method to write packets rather than WritePacket:
Expand Down Expand Up @@ -54,8 +53,6 @@ class GoQuicServerPacketWriter : public QuicPacketWriter {
private:
void* go_udp_conn_;

void* go_task_runner_;

// To be notified after every successful asynchronous write.
QuicBlockedWriterInterface* blocked_writer_;

Expand Down

0 comments on commit 7d98072

Please sign in to comment.