|
1 | 1 | package ibmmq |
2 | 2 |
|
3 | 3 | /* |
4 | | - Copyright (c) IBM Corporation 2016,2018 |
| 4 | + Copyright (c) IBM Corporation 2016,2019 |
5 | 5 |
|
6 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); |
7 | 7 | you may not use this file except in compliance with the License. |
@@ -31,6 +31,7 @@ import ( |
31 | 31 | "encoding/binary" |
32 | 32 | "encoding/hex" |
33 | 33 | "fmt" |
| 34 | + "runtime/debug" |
34 | 35 | ) |
35 | 36 |
|
36 | 37 | /* |
@@ -121,7 +122,12 @@ func (cfh *MQCFH) Bytes() []byte { |
121 | 122 |
|
122 | 123 | /* |
123 | 124 | Bytes serialises a PCFParameter into the C structure |
124 | | -corresponding to its type |
| 125 | +corresponding to its type. |
| 126 | +
|
| 127 | +TODO: Only a subset of the PCF |
| 128 | +parameter types are handled here - those needed for |
| 129 | +command queries. Other types could be added if |
| 130 | +necessary later. |
125 | 131 | */ |
126 | 132 | func (p *PCFParameter) Bytes() []byte { |
127 | 133 | var buf []byte |
@@ -173,7 +179,7 @@ func (p *PCFParameter) Bytes() []byte { |
173 | 179 | offset += 4 |
174 | 180 | copy(buf[offset:], []byte(p.String[0])) |
175 | 181 | default: |
176 | | - fmt.Println("mqiPCF.go: Trying to serialise PCF parameter. Unknown PCF type ", p.Type) |
| 182 | + fmt.Printf("mqiPCF.go: Trying to serialise PCF parameter. Unknown PCF type %d\n", p.Type) |
177 | 183 | } |
178 | 184 | return buf |
179 | 185 | } |
@@ -224,8 +230,8 @@ func ReadPCFParameter(buf []byte) (*PCFParameter, int) { |
224 | 230 | binary.Read(p, endian, &pcfParm.strucLength) |
225 | 231 |
|
226 | 232 | switch pcfParm.Type { |
227 | | - // There are more PCF element types but the samples only |
228 | | - // needed a subset |
| 233 | + // There are more PCF element types but the monitoring packages only |
| 234 | + // needed a subset. We can add the others later if necessary. |
229 | 235 | case C.MQCFT_INTEGER: |
230 | 236 | binary.Read(p, endian, &pcfParm.Parameter) |
231 | 237 | binary.Read(p, endian, &i32) |
@@ -289,7 +295,14 @@ func ReadPCFParameter(buf []byte) (*PCFParameter, int) { |
289 | 295 | p.Next(int(pcfParm.strucLength - offset)) |
290 | 296 |
|
291 | 297 | default: |
292 | | - fmt.Println("mqiPCF.go: Unknown PCF type ", pcfParm.Type) |
| 298 | + // This should not happen, but if it does then dump various pieces of |
| 299 | + // debug information that might help solve the problem. |
| 300 | + // TODO: Put this in something like an environment variable control option |
| 301 | + localerr := fmt.Errorf("mqiPCF.go: Unknown PCF type %d", pcfParm.Type) |
| 302 | + fmt.Println("Error: ", localerr) |
| 303 | + fmt.Println("Buffer: ", buf) |
| 304 | + debug.PrintStack() |
| 305 | + // After dumping the stack, we will try to carry on regardless. |
293 | 306 | // Skip the remains of this structure, assuming it really is |
294 | 307 | // PCF and we just don't know how to process the element type |
295 | 308 | p.Next(int(pcfParm.strucLength - 8)) |
|
0 commit comments