summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/lib/pq/conn.go
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2018-04-16 05:37:14 -0700
committerJoram Wilander <jwawilander@gmail.com>2018-04-16 08:37:14 -0400
commit6e2cb00008cbf09e556b00f87603797fcaa47e09 (patch)
tree3c0eb55ff4226a3f024aad373140d1fb860a6404 /vendor/github.com/lib/pq/conn.go
parentbf24f51c4e1cc6286885460672f7f449e8c6f5ef (diff)
downloadchat-6e2cb00008cbf09e556b00f87603797fcaa47e09.tar.gz
chat-6e2cb00008cbf09e556b00f87603797fcaa47e09.tar.bz2
chat-6e2cb00008cbf09e556b00f87603797fcaa47e09.zip
Depenancy upgrades and movign to dep. (#8630)
Diffstat (limited to 'vendor/github.com/lib/pq/conn.go')
-rw-r--r--vendor/github.com/lib/pq/conn.go31
1 files changed, 20 insertions, 11 deletions
diff --git a/vendor/github.com/lib/pq/conn.go b/vendor/github.com/lib/pq/conn.go
index de6e5c17c..43c8df29f 100644
--- a/vendor/github.com/lib/pq/conn.go
+++ b/vendor/github.com/lib/pq/conn.go
@@ -340,7 +340,12 @@ func DialOpen(d Dialer, name string) (_ driver.Conn, err error) {
return nil, err
}
- // cn.ssl and cn.startup panic on error. Make sure we don't leak cn.c.
+ err = cn.ssl(o)
+ if err != nil {
+ return nil, err
+ }
+
+ // cn.startup panics on error. Make sure we don't leak cn.c.
panicking := true
defer func() {
if panicking {
@@ -348,7 +353,6 @@ func DialOpen(d Dialer, name string) (_ driver.Conn, err error) {
}
}()
- cn.ssl(o)
cn.buf = bufio.NewReader(cn.c)
cn.startup(o)
@@ -1029,30 +1033,35 @@ func (cn *conn) recv1() (t byte, r *readBuf) {
return t, r
}
-func (cn *conn) ssl(o values) {
- upgrade := ssl(o)
+func (cn *conn) ssl(o values) error {
+ upgrade, err := ssl(o)
+ if err != nil {
+ return err
+ }
+
if upgrade == nil {
// Nothing to do
- return
+ return nil
}
w := cn.writeBuf(0)
w.int32(80877103)
- if err := cn.sendStartupPacket(w); err != nil {
- panic(err)
+ if err = cn.sendStartupPacket(w); err != nil {
+ return err
}
b := cn.scratch[:1]
- _, err := io.ReadFull(cn.c, b)
+ _, err = io.ReadFull(cn.c, b)
if err != nil {
- panic(err)
+ return err
}
if b[0] != 'S' {
- panic(ErrSSLNotSupported)
+ return ErrSSLNotSupported
}
- cn.c = upgrade(cn.c)
+ cn.c, err = upgrade(cn.c)
+ return err
}
// isDriverSetting returns true iff a setting is purely for configuring the